package com.fintech.third.service.bairong;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSON;
import com.fintech.common.enums.RespStatus;
import com.fintech.common.service.BaseServiceImpl;
import com.fintech.common.util.ApiResponse;
import com.fintech.common.util.PropertiesUtils;
import com.fintech.datagroud.dao.bairong.EdcBRDataQueryLogInfoMapper;
import com.fintech.datagroud.dao.bairong.EdcBrSignequipmentMapper;
import com.fintech.datagroud.dao.bairong.IntBrRegisterEquipmentMapper;
import com.fintech.datagroud.entity.bairong.EdcBrRuleResult;
import com.fintech.datagroud.entity.bairong.EdcBrRuleResultDetail;
import com.fintech.datagroud.service.DGBaiRongService;
import com.fintech.third.constant.LocalStatus;
import com.fintech.third.constant.ThirdMethodConstants;
import com.fintech.third.constant.ThirdProductChannelConstant;
import com.fintech.third.model.EquipmentInfor;
import com.fintech.third.model.ThirdProperties;
import com.fintech.third.model.bairong.AirTravelLevel;
import com.fintech.third.model.bairong.ApplicationInfoAssociate;
import com.fintech.third.model.bairong.Applications;
import com.fintech.third.model.bairong.BadInformation;
import com.fintech.third.model.bairong.BankcardCheck;
import com.fintech.third.model.bairong.BankcardCheckThree;
import com.fintech.third.model.bairong.BddPackAllInterfaceInfo;
import com.fintech.third.model.bairong.BizInfo;
import com.fintech.third.model.bairong.BizInfoKey;
import com.fintech.third.model.bairong.BizInvest;
import com.fintech.third.model.bairong.BizInvestMap;
import com.fintech.third.model.bairong.ConsumAbbility;
import com.fintech.third.model.bairong.CreditRiskEvaluation;
import com.fintech.third.model.bairong.CurrentEquipmentInformationReport;
import com.fintech.third.model.bairong.CurrentEquipmentPackageInfo;
import com.fintech.third.model.bairong.DishonestEnterprise;
import com.fintech.third.model.bairong.DishonestExecutor;
import com.fintech.third.model.bairong.EdcBRDataQueryLogInfo;
import com.fintech.third.model.bairong.EdcBrRuleFlagSign;
import com.fintech.third.model.bairong.EductionInformation;
import com.fintech.third.model.bairong.EquipmentInfo;
import com.fintech.third.model.bairong.EquipmentSpecialList;
import com.fintech.third.model.bairong.IdCardCheck;
import com.fintech.third.model.bairong.IncomeLevel;
import com.fintech.third.model.bairong.IncomeMonthLevel;
import com.fintech.third.model.bairong.LoanFacilityInformation;
import com.fintech.third.model.bairong.LoanFacilityPackageInfo;
import com.fintech.third.model.bairong.LoginFacilityInformation;
import com.fintech.third.model.bairong.LoginFacilityPackageInfo;
import com.fintech.third.model.bairong.MallBrAllInterfaceInfo;
import com.fintech.third.model.bairong.MediaReading;
import com.fintech.third.model.bairong.MicroCreditLevel;
import com.fintech.third.model.bairong.MicroPaymentConsum;
import com.fintech.third.model.bairong.MultipleApplications;
import com.fintech.third.model.bairong.OccApplyLoanInfo;
import com.fintech.third.model.bairong.PayBehavior;
import com.fintech.third.model.bairong.PaymentConsum;
import com.fintech.third.model.bairong.PerInvest;
import com.fintech.third.model.bairong.ReceiveAndConsumLevel;
import com.fintech.third.model.bairong.RegisterFacilityInformation;
import com.fintech.third.model.bairong.RegisterFacilityPackageInfo;
import com.fintech.third.model.bairong.RuleInformation;
import com.fintech.third.model.bairong.Score;
import com.fintech.third.model.bairong.SocietyRelation;
import com.fintech.third.model.bairong.SpecialList;
import com.fintech.third.model.bairong.Stability;
import com.fintech.third.model.bairong.TelCheck;
import com.fintech.third.model.bairong.TelStatus;
import com.fintech.third.model.bairong.TelTwoInformation;
import com.fintech.third.model.bairong.VehicleViolation;
import com.fintech.third.utils.ThirdPropertiesInitUtil;
import com.fintech.third.utils.bairong.BaiRongUtil;
import com.marvels.common.utils.MarvelsLogUtil;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

/**
 * 百融数据
 * 
 * @title BaiRongImpl
 * @author tuxu
 * @date 2018年9月25日
 */
@Service("BaiRong")
public class BaiRongImpl extends BaseServiceImpl implements BaiRongService {

	@Autowired
	private DGBaiRongService dGBaiRongService;

	@Autowired
	private EdcBrSignequipmentMapper edcBrSignequipmentMapper;

	@Autowired
	private IntBrRegisterEquipmentMapper intBrRegisterEquipmentMapper;
	@Autowired
	private EdcBRDataQueryLogInfoMapper edcBRDataQueryLogInfoMapper;

	/**
	 * 登录百融方法
	 * 
	 * @return tokenId 任务Id
	 */
	public String platLogin() {
		ThirdProperties thirdProperties = ThirdPropertiesInitUtil.getThirdProperties();
		JSONObject json = new JSONObject();
		json.put("userName", thirdProperties.getBr_merchantName());
		json.put("password", thirdProperties.getBr_merchantPwd());
		json.put("apiCode", thirdProperties.getBr_apiCode());
		String result = "";
		String tokenId = "";

		try {
			result = BaiRongUtil.urlConnectPost(thirdProperties.getBr_loginRequestUrl(),
					"userName=" + thirdProperties.getBr_merchantName() + "&password="
							+ thirdProperties.getBr_merchantPwd() + "&apiCode=" + thirdProperties.getBr_apiCode());
			MarvelsLogUtil.getInstance().info("=============平台登录百融返回信息:" + result);
			if (StringUtils.isNotEmpty(result)) {
				JSONObject resultJson = new JSONObject();
				resultJson = JSONObject.fromObject(result);
				if (resultJson.get("code").toString().equals("00")) {
					tokenId = resultJson.get("tokenid").toString();
				}
			}
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error("========百融登录异常========", e);
		}

		return tokenId;
	}

	@Override
	public ApiResponse<SpecialList> specialListReport(JSONObject json, String serialNum, String loanId,
			String channel) {
		ApiResponse<SpecialList> resp = new ApiResponse<SpecialList>();
		/*
		 * 如果接口停用，直接返回（视具体情况，有的返回停用，有的返回相关值） ADD BY TUXU 2018-05-31
		 */
		if (PropertiesUtils.isTurnOffForSwitch("switch.br0001")) {
			// RespStatus.DISABLE只有接口停用时才使用定义的这个参数，其它情况按原本的来
			resp.setCode(RespStatus.DISABLE.getCode());
			resp.setMsg(RespStatus.DISABLE.getMsg());
			return resp;
		}
		ThirdProperties thirdProperties = ThirdPropertiesInitUtil.getThirdProperties();
		Date startDate = Calendar.getInstance().getTime();
		String result = "";
		String code = "";
		String status = LocalStatus.REQUEST_FAIL.getCode();// 请求失败
		SpecialList specialList = new SpecialList();
		String tokenId = platLogin();
		if (StringUtils.isEmpty(tokenId)) {
			resp.setCode(RespStatus.REQ_ERROR.getCode());
			resp.setMsg(RespStatus.REQ_ERROR.getMsg());
		} else {
			try {
				result = BaiRongUtil.urlConnectPost(thirdProperties.getBr_packetRequestUrl(),
						"tokenid=" + tokenId + "&apiCode=" + thirdProperties.getBr_apiCode() + "&jsonData="
								+ URLEncoder.encode(json.toString(), "utf-8") + "&checkCode="
								+ BaiRongUtil.getCheckData(json.toString(), thirdProperties.getBr_apiCode(), tokenId));
			} catch (Exception e) {
				MarvelsLogUtil.getInstance().error(">>>>>>>>>百融specialListReport接口请求异常：", e);
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
			MarvelsLogUtil.getInstance().info("获取特殊名单核查报告返回信息:" + result);
			if (StringUtils.isNotEmpty(result)) {
				status = LocalStatus.IN_DATABASE_FAIL.getCode();
				JSONObject resultJson = new JSONObject();
				resultJson = JSONObject.fromObject(result);
				code = resultJson.get("code").toString();
				if (code.equals("00") || code.equals("100002")) {
					specialList = JSON.parseObject(result, SpecialList.class);
					if (code.equals("00")) {
						status = LocalStatus.SUCCESS_WITH_DATA.getCode();
					} else {
						status = LocalStatus.SUCCESS_WITHOUT_DATA.getCode();
					}
					resp.setCode(RespStatus.SUCCESS.getCode());
					resp.setMsg(RespStatus.SUCCESS.getMsg());
					resp.setData(specialList);
					// 数据落地
					try {
						dGBaiRongService.specialListReport(specialList, serialNum, loanId);
					} catch (Exception e) {
						MarvelsLogUtil.getInstance().error(">>>>>>>>>百融specialListReport数据落地失败：", e);
						status = LocalStatus.IN_DATABASE_FAIL.getCode();
						resp.setCode(RespStatus.DATABASE_ERROR.getCode());
						resp.setMsg(RespStatus.DATABASE_ERROR.getMsg());
					}
				} else {
					resp.setCode(RespStatus.REQ_ERROR.getCode());
					status = LocalStatus.CALL_SUCCESS.getCode();
					resp.setMsg("调用百融接口,返回错误码：" + code);
				}
			} else {
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
		}
		saveDataQueryLogNew(serialNum, loanId, null, specialList.getSwift_number(), startDate,
				ThirdMethodConstants.BR0001, code, status, "edc_br_data_query_log", json.getString("id"));
		return resp;
	}

	/**
	 * 多次申请核查v2(用户近7/15天、1/3/6个月在百融的虚拟信贷联盟(银行、非银、非银细分类型)中的多次信贷申请情况)
	 * 
	 * @param json
	 * @return
	 */
	@Override
	public ApiResponse<MultipleApplications> multipleApplicationsReport(JSONObject json, String serialNum,
			String loanId, String channel) {
		ApiResponse<MultipleApplications> resp = new ApiResponse<MultipleApplications>();
		/*
		 * 如果接口停用，直接返回（视具体情况，有的返回停用，有的返回相关值） ADD BY TUXU 2018-05-31
		 */
		if (PropertiesUtils.isTurnOffForSwitch("switch.br0002")) {
			// RespStatus.DISABLE只有接口停用时才使用定义的这个参数，其它情况按原本的来
			resp.setCode(RespStatus.DISABLE.getCode());
			resp.setMsg(RespStatus.DISABLE.getMsg());
			return resp;
		}
		ThirdProperties thirdProperties = ThirdPropertiesInitUtil.getThirdProperties();
		MultipleApplications multipleApplications = new MultipleApplications();
		String result = "";
		String code = "";
		String status = LocalStatus.REQUEST_FAIL.getCode();// 请求失败
		Date sTime = new Date();
		String tokenId = platLogin();
		if (StringUtils.isEmpty(tokenId)) {
			resp.setCode(RespStatus.REQ_ERROR.getCode());
			resp.setMsg(RespStatus.REQ_ERROR.getMsg());
		} else {
			try {
				MarvelsLogUtil.getInstance().info(loanId + "获取用户多次申请核查v2报告请求信息:" + URLEncoder.encode(json.toString(), "utf-8"));
				result = BaiRongUtil.urlConnectPost(thirdProperties.getBr_packetRequestUrl(),
						"tokenid=" + tokenId + "&apiCode=" + thirdProperties.getBr_apiCode() + "&jsonData="
								+ URLEncoder.encode(json.toString(), "utf-8") + "&checkCode="
								+ BaiRongUtil.getCheckData(json.toString(), thirdProperties.getBr_apiCode(), tokenId));
			} catch (Exception e) {
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
				MarvelsLogUtil.getInstance().error(">>>>>>>>>>>百融多次申请核查v2请求异常", e);
			}
			MarvelsLogUtil.getInstance().info(loanId + "获取用户多次申请核查v2报告返回信息:" + result);
			if (StringUtils.isNotEmpty(result)) {
				status = LocalStatus.IN_DATABASE_FAIL.getCode();
				multipleApplications = JSON.parseObject(result, MultipleApplications.class);
				JSONObject resultJson = new JSONObject();
				resultJson = JSONObject.fromObject(result);
				code = resultJson.get("code").toString();
				if (code.equals("00") || code.equals("100002")) {
					if (code.equals("00")) {
						status = LocalStatus.SUCCESS_WITH_DATA.getCode();
					} else {
						status = LocalStatus.SUCCESS_WITHOUT_DATA.getCode();
					}
					resp.setCode(RespStatus.SUCCESS.getCode());
					resp.setMsg(RespStatus.SUCCESS.getMsg());
					resp.setData(multipleApplications);
					// 数据落地
					try {
						dGBaiRongService.multipleApplicationsReport(multipleApplications, serialNum, loanId);
					} catch (Exception e) {
						resp.setCode(RespStatus.DATABASE_ERROR.getCode());
						resp.setMsg(RespStatus.DATABASE_ERROR.getMsg());
						status = LocalStatus.IN_DATABASE_FAIL.getCode();
						MarvelsLogUtil.getInstance().error(">>>>>>>>>>>百融多次申请核查v2落库异常", e);
					}
				} else {
					resp.setCode(RespStatus.REQ_ERROR.getCode());
					resp.setMsg("调用百融接口,返回错误码：" + code);
					status = LocalStatus.CALL_SUCCESS.getCode();
				}
			} else {
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
		}
		saveDataQueryLogNew(serialNum, loanId, json.getString("cell"), multipleApplications.getSwift_number(), sTime,
				ThirdMethodConstants.BR0002, code, status, "edc_br_data_query_log", null);
		return resp;
	}

	@Override
	public ApiResponse<Stability> stabilityReport(JSONObject json, String serialNum, String loanId, String channel) {
		ApiResponse<Stability> resp = new ApiResponse<Stability>();
		/*
		 * 如果接口停用，直接返回（视具体情况，有的返回停用，有的返回相关值） ADD BY TUXU 2018-05-31
		 */
		if (PropertiesUtils.isTurnOffForSwitch("switch.br0003")) {
			// RespStatus.DISABLE只有接口停用时才使用定义的这个参数，其它情况按原本的来
			resp.setCode(RespStatus.DISABLE.getCode());
			resp.setMsg(RespStatus.DISABLE.getMsg());
			return resp;
		}
		ThirdProperties thirdProperties = ThirdPropertiesInitUtil.getThirdProperties();
		Date sTime = new Date();
		Stability stability = new Stability();
		String result = "";
		String code = "";
		String status = LocalStatus.REQUEST_FAIL.getCode();// 请求失败
		String tokenId = platLogin();
		if (StringUtils.isEmpty(tokenId)) {
			resp.setCode(RespStatus.REQ_ERROR.getCode());
			resp.setMsg(RespStatus.REQ_ERROR.getMsg());
		} else {
			try {

				result = BaiRongUtil.urlConnectPost(thirdProperties.getBr_packetRequestUrl(),
						"tokenid=" + tokenId + "&apiCode=" + thirdProperties.getBr_apiCode() + "&jsonData="
								+ URLEncoder.encode(json.toString(), "utf-8") + "&checkCode="
								+ BaiRongUtil.getCheckData(json.toString(), thirdProperties.getBr_apiCode(), tokenId));
			} catch (UnsupportedEncodingException e) {
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
				MarvelsLogUtil.getInstance().error(">>>>>>>>>>百融stabilityReport请求异常:", e);
			}
			MarvelsLogUtil.getInstance().info("获取稳定性评估报告返回信息:" + result);
			if (StringUtils.isNotEmpty(result)) {
				status = LocalStatus.IN_DATABASE_FAIL.getCode();
				stability = JSON.parseObject(result, Stability.class);
				JSONObject resultJson = new JSONObject();
				resultJson = JSONObject.fromObject(result);
				code = resultJson.get("code").toString();
				if (code.equals("00") || code.equals("100002")) {
					if (code.equals("00")) {
						status = LocalStatus.SUCCESS_WITH_DATA.getCode();
					} else {
						status = LocalStatus.SUCCESS_WITHOUT_DATA.getCode();
					}
					resp.setCode(RespStatus.SUCCESS.getCode());
					resp.setMsg(RespStatus.SUCCESS.getMsg());
					resp.setData(stability);
					// 数据落地
					try {
						dGBaiRongService.stabilityReport(stability, serialNum, loanId);
					} catch (Exception e) {
						resp.setCode(RespStatus.DATABASE_ERROR.getCode());
						resp.setMsg(RespStatus.DATABASE_ERROR.getMsg());
						status = LocalStatus.IN_DATABASE_FAIL.getCode();
						MarvelsLogUtil.getInstance().error(">>>>>>>>>>百融stabilityReport落库异常:", e);
					}
				} else {
					status = LocalStatus.CALL_SUCCESS.getCode();
					resp.setCode(RespStatus.REQ_ERROR.getCode());
					resp.setMsg("调用百融接口,返回错误码：" + code);
				}
			} else {
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
		}
		saveDataQueryLogNew(serialNum, loanId, null, stability.getSwift_number(), sTime, ThirdMethodConstants.BR0003,
				code, status, "edc_br_data_query_log", null);
		return resp;
	}
	
	@Override
	public ApiResponse<IncomeLevel> incomeLevelReport(JSONObject json, String serialNum, String loanId,
			String channel) {
		ApiResponse<IncomeLevel> resp = new ApiResponse<IncomeLevel>();
		/*
		 * 如果接口停用，直接返回（视具体情况，有的返回停用，有的返回相关值） ADD BY TUXU 2018-05-31
		 */
		if (PropertiesUtils.isTurnOffForSwitch("switch.br0004")) {
			// RespStatus.DISABLE只有接口停用时才使用定义的这个参数，其它情况按原本的来
			resp.setCode(RespStatus.DISABLE.getCode());
			resp.setMsg(RespStatus.DISABLE.getMsg());
			return resp;
		}
		ThirdProperties thirdProperties = ThirdPropertiesInitUtil.getThirdProperties();
		Date sTime = new Date();
		IncomeLevel incomeLevel = new IncomeLevel();
		String result = "";
		String status = LocalStatus.REQUEST_FAIL.getCode();
		String code = "";
		String tokenId = platLogin();
		if (StringUtils.isEmpty(tokenId)) {
			resp.setCode(RespStatus.REQ_ERROR.getCode());
			resp.setMsg(RespStatus.REQ_ERROR.getMsg());
		} else {
			try {

				result = BaiRongUtil.urlConnectPost(thirdProperties.getBr_packetRequestUrl(),
						"tokenid=" + tokenId + "&apiCode=" + thirdProperties.getBr_apiCode() + "&jsonData="
								+ URLEncoder.encode(json.toString(), "utf-8") + "&checkCode="
								+ BaiRongUtil.getCheckData(json.toString(), thirdProperties.getBr_apiCode(), tokenId));
			} catch (UnsupportedEncodingException e) {
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
				MarvelsLogUtil.getInstance().error(">>>>>>>>百融月度收支等级评估请求异常:", e);
			}
			MarvelsLogUtil.getInstance().info("获取月度收支等级评估报告返回信息:" + result);
			if (StringUtils.isNotEmpty(result)) {
				status = LocalStatus.CALL_SUCCESS.getCode();
				incomeLevel = JSON.parseObject(result, IncomeLevel.class);
				JSONObject resultJson = new JSONObject();
				resultJson = JSONObject.fromObject(result);
				code = resultJson.get("code").toString();
				if (code.equals("00") || code.equals("100002")) {
					if (code.equals("00")) {
						status = LocalStatus.SUCCESS_WITH_DATA.getCode();
					} else {
						status = LocalStatus.SUCCESS_WITHOUT_DATA.getCode();
					}
					resp.setCode(RespStatus.SUCCESS.getCode());
					resp.setMsg(RespStatus.SUCCESS.getMsg());
					resp.setData(incomeLevel);
				} else {
					resp.setCode(RespStatus.REQ_ERROR.getCode());
					resp.setMsg("调用百融接口,返回错误码：" + code);
					status = LocalStatus.CALL_SUCCESS.getCode();
				}
			} else {
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
		}

		saveDataQueryLogNew(serialNum, loanId, null, incomeLevel.getSwift_number(), sTime, ThirdMethodConstants.BR0004,
				code, status, "edc_br_data_query_log", null);
		return resp;
	}
	
	@Override
	public ApiResponse<LoanFacilityInformation> loanFacilityInformationReport(JSONObject json, String serialNum,
			String loanId, String channel) {
		ApiResponse<LoanFacilityInformation> resp = new ApiResponse<LoanFacilityInformation>();
		/*
		 * 如果接口停用，直接返回（视具体情况，有的返回停用，有的返回相关值） ADD BY TUXU 2018-05-31
		 */
		if (PropertiesUtils.isTurnOffForSwitch("switch.br0005")) {
			// RespStatus.DISABLE只有接口停用时才使用定义的这个参数，其它情况按原本的来
			resp.setCode(RespStatus.DISABLE.getCode());
			resp.setMsg(RespStatus.DISABLE.getMsg());
			return resp;
		}
		ThirdProperties thirdProperties = ThirdPropertiesInitUtil.getThirdProperties();
		String mobile = JSONArray.fromObject(json.get("cell")).getString(0);
		String tokenId = platLogin();
		Date sTime = new Date();
		String result = "";
		String code = "";
		String status = LocalStatus.REQUEST_FAIL.getCode();
		;
		LoanFacilityInformation loanFacilityInformation = new LoanFacilityInformation();
		if (StringUtils.isEmpty(tokenId)) {
			resp.setCode(RespStatus.REQ_ERROR.getCode());
			resp.setMsg(RespStatus.REQ_ERROR.getMsg());
		} else {
			try {
				result = BaiRongUtil.urlConnectPost(thirdProperties.getBr_packetRequestUrl(),
						"tokenid=" + tokenId + "&apiCode=" + thirdProperties.getBr_apiCode() + "&jsonData="
								+ URLEncoder.encode(json.toString(), "utf-8") + "&checkCode="
								+ BaiRongUtil.getCheckData(json.toString(), thirdProperties.getBr_apiCode(), tokenId));
//				result = BaiRongUtil.urlConnectPost("https://sandbox-api.100credit.cn/bankServer2/data/terData.action",
//						"tokenid=" + tokenId + "&apiCode=" + thirdProperties.getBr_apiCode() + "&jsonData="
//								+ URLEncoder.encode(json.toString(), "utf-8") + "&checkCode="
//								+ BaiRongUtil.getCheckData(json.toString(), thirdProperties.getBr_apiCode(), tokenId));
			} catch (Exception e) {
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
				MarvelsLogUtil.getInstance().error(">>>>>>>>>百融借款设备返回信息请求异常", e);
			}
			MarvelsLogUtil.getInstance().info("==============>>>>百融借款设备返回信息:" + result);
			if (StringUtils.isNotEmpty(result)) {
				status = LocalStatus.IN_DATABASE_FAIL.getCode();
				loanFacilityInformation = JSON.parseObject(result, LoanFacilityInformation.class);
				JSONObject resultJson = new JSONObject();
				resultJson = JSONObject.fromObject(result);
				code = resultJson.get("code").toString();
				if (code.equals("00") || code.equals("100002")) {
					if (code.equals("00")) {
						status = LocalStatus.SUCCESS_WITH_DATA.getCode();
					} else {
						status = LocalStatus.SUCCESS_WITHOUT_DATA.getCode();
					}
					resp.setCode(RespStatus.SUCCESS.getCode());
					resp.setMsg(RespStatus.SUCCESS.getMsg());
					resp.setData(loanFacilityInformation);
					// 数据落地
					try {
						dGBaiRongService.loanFacilityInformationReport(loanFacilityInformation, serialNum, loanId,
								mobile);
					} catch (Exception e) {
						resp.setCode(RespStatus.DATABASE_ERROR.getCode());
						resp.setMsg(RespStatus.DATABASE_ERROR.getMsg());
						status = LocalStatus.IN_DATABASE_FAIL.getCode();
						MarvelsLogUtil.getInstance().error(">>>>>>>>>百融借款设备数据落地失败：" + e);
					}
				} else {
					status = LocalStatus.CALL_SUCCESS.getCode();
					resp.setCode(RespStatus.REQ_ERROR.getCode());
					resp.setMsg("调用百融接口,返回错误码：" + code);
					status = LocalStatus.CALL_SUCCESS.getCode();
				}
			} else {
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
		}

		saveDataQueryLogNew(serialNum, loanId, "", loanFacilityInformation.getSwift_number(), sTime,
				ThirdMethodConstants.BR0005, code, status, "edc_br_data_query_log", null);
		return resp;
	}

	@Override
	public ApiResponse<RegisterFacilityInformation> registerFacilityInformationReport(JSONObject json, String serialNum,
			String loanId, String channel) {
		ApiResponse<RegisterFacilityInformation> resp = new ApiResponse<RegisterFacilityInformation>();
		/*
		 * 如果接口停用，直接返回（视具体情况，有的返回停用，有的返回相关值） ADD BY TUXU 2018-05-31
		 */
		if (PropertiesUtils.isTurnOffForSwitch("switch.br0006")) {
			// RespStatus.DISABLE只有接口停用时才使用定义的这个参数，其它情况按原本的来
			resp.setCode(RespStatus.DISABLE.getCode());
			resp.setMsg(RespStatus.DISABLE.getMsg());
			return resp;
		}
		ThirdProperties thirdProperties = ThirdPropertiesInitUtil.getThirdProperties();
		String mobile = JSONArray.fromObject(json.get("cell")).getString(0);
		String tokenId = platLogin();
		RegisterFacilityInformation registerFacilityInformation = new RegisterFacilityInformation();
		String result = "";
		String code = "";
		String status = LocalStatus.REQUEST_FAIL.getCode();
		Date sTime = new Date();
		serialNum = serialNum + mobile;
		if (StringUtils.isEmpty(tokenId)) {

			resp.setCode(RespStatus.REQ_ERROR.getCode());
			resp.setMsg(RespStatus.REQ_ERROR.getMsg());
		} else {

			try {

				result = BaiRongUtil.urlConnectPost(thirdProperties.getBr_packetRequestUrl(),
						"tokenid=" + tokenId + "&apiCode=" + thirdProperties.getBr_apiCode() + "&jsonData="
								+ URLEncoder.encode(json.toString(), "utf-8") + "&checkCode="
								+ BaiRongUtil.getCheckData(json.toString(), thirdProperties.getBr_apiCode(), tokenId));
//				result = BaiRongUtil.urlConnectPost("https://sandbox-api.100credit.cn/bankServer2/data/terData.action",
//						"tokenid=" + tokenId + "&apiCode=" + thirdProperties.getBr_apiCode() + "&jsonData="
//								+ URLEncoder.encode(json.toString(), "utf-8") + "&checkCode="
//								+ BaiRongUtil.getCheckData(json.toString(), thirdProperties.getBr_apiCode(), tokenId));
			} catch (Exception e) {
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
				MarvelsLogUtil.getInstance().error(">>>>>>>>>>百融注册设备信息请求异常:", e);
			}
			MarvelsLogUtil.getInstance().info("==============>>>>百融注册设备信息返回信息:" + result);
			if (StringUtils.isNotEmpty(result)) {
				status = LocalStatus.IN_DATABASE_FAIL.getCode();
				registerFacilityInformation = JSON.parseObject(result, RegisterFacilityInformation.class);
				JSONObject resultJson = new JSONObject();
				resultJson = JSONObject.fromObject(result);
				code = resultJson.get("code").toString();
				if (code.equals("00") || code.equals("100002")) {
					if (code.equals("00")) {
						status = LocalStatus.SUCCESS_WITH_DATA.getCode();
					} else {
						status = LocalStatus.SUCCESS_WITHOUT_DATA.getCode();
					}
					resp.setCode(RespStatus.SUCCESS.getCode());
					resp.setMsg(RespStatus.SUCCESS.getMsg());
					resp.setData(registerFacilityInformation);
					// 数据落地
					try {
						dGBaiRongService.registerFacilityInformationReport(registerFacilityInformation, serialNum,
								loanId, mobile);
					} catch (Exception e) {
						status = LocalStatus.IN_DATABASE_FAIL.getCode();
						resp.setCode(RespStatus.DATABASE_ERROR.getCode());
						resp.setMsg(RespStatus.DATABASE_ERROR.getMsg());
						MarvelsLogUtil.getInstance().error(">>>>>>>>>>百融注册设备信息数据落地失败：", e);
					}
				} else {
					status = LocalStatus.CALL_SUCCESS.getCode();
					resp.setCode(RespStatus.REQ_ERROR.getCode());
					resp.setMsg("调用百融接口,返回错误码：" + code);
				}
			} else {
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
		}
		saveDataQueryLogNew(serialNum, loanId, "", registerFacilityInformation.getSwift_number(), sTime,
				ThirdMethodConstants.BR0006, code, status, "edc_br_data_query_log", null);
		return resp;
	}

	@Override
	public ApiResponse<LoginFacilityInformation> loginFacilityInformationReport(JSONObject json, String serialNum,
			String loanId, String channel) {
		ApiResponse<LoginFacilityInformation> resp = new ApiResponse<LoginFacilityInformation>();
		/*
		 * 如果接口停用，直接返回（视具体情况，有的返回停用，有的返回相关值） ADD BY TUXU 2018-05-31
		 */
		if (PropertiesUtils.isTurnOffForSwitch("switch.br0007")) {
			// RespStatus.DISABLE只有接口停用时才使用定义的这个参数，其它情况按原本的来
			resp.setCode(RespStatus.DISABLE.getCode());
			resp.setMsg(RespStatus.DISABLE.getMsg());
			return resp;
		}
		ThirdProperties thirdProperties = ThirdPropertiesInitUtil.getThirdProperties();
		String tokenId = platLogin();
		LoginFacilityInformation loginFacilityInformation = new LoginFacilityInformation();
		String result = "";
		String code = "";
		String status = LocalStatus.REQUEST_FAIL.getCode();
		Date sTime = new Date();
		String mobile = JSONArray.fromObject(json.get("cell")).getString(0);
		serialNum = serialNum + mobile;
		if (StringUtils.isEmpty(tokenId)) {
			resp.setCode(RespStatus.REQ_ERROR.getCode());
			resp.setMsg(RespStatus.REQ_ERROR.getMsg());
		} else {
			JSONObject jsonObject = new JSONObject();
			jsonObject.put("", "");
			MarvelsLogUtil.getInstance().info("==============>>>>百融登录设备信息请求信息:" + json.toString());
			try {
				result = BaiRongUtil.urlConnectPost(thirdProperties.getBr_packetRequestUrl(),
						"tokenid=" + tokenId + "&apiCode=" + thirdProperties.getBr_apiCode() + "&jsonData="
								+ URLEncoder.encode(json.toString(), "utf-8") + "&checkCode="
								+ BaiRongUtil.getCheckData(json.toString(), thirdProperties.getBr_apiCode(), tokenId));
//				result = BaiRongUtil.urlConnectPost("https://sandbox-api.100credit.cn/bankServer2/data/terData.action",
//						"tokenid=" + tokenId + "&apiCode=" + thirdProperties.getBr_apiCode() + "&jsonData="
//								+ URLEncoder.encode(json.toString(), "utf-8") + "&checkCode="
//								+ BaiRongUtil.getCheckData(json.toString(), thirdProperties.getBr_apiCode(), tokenId));
			} catch (Exception e) {
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
				MarvelsLogUtil.getInstance().error(">>>>>>>>>>>百融登录设备信息请求:", e);
			}
			MarvelsLogUtil.getInstance().info("==============>>>>百融登录设备信息返回信息:" + result);
			if (StringUtils.isNotEmpty(result)) {
				status = LocalStatus.IN_DATABASE_FAIL.getCode();
				loginFacilityInformation = JSON.parseObject(result, LoginFacilityInformation.class);
				JSONObject resultJson = new JSONObject();
				resultJson = JSONObject.fromObject(result);
				code = resultJson.get("code").toString();
				if (code.equals("00") || code.equals("100002")) {
					if (code.equals("00")) {
						status = LocalStatus.SUCCESS_WITH_DATA.getCode();
					} else {
						status = LocalStatus.SUCCESS_WITHOUT_DATA.getCode();
					}
					resp.setCode(RespStatus.SUCCESS.getCode());
					resp.setMsg(RespStatus.SUCCESS.getMsg());
					resp.setData(loginFacilityInformation);
					// 数据落地
					try {
						dGBaiRongService.loginFacilityInformationReport(loginFacilityInformation, serialNum, loanId,
								mobile);
					} catch (Exception e) {
						MarvelsLogUtil.getInstance().error(">>>>>>>>>>>百融登录设备信息落库:" + e);
						resp.setCode(RespStatus.DATABASE_ERROR.getCode());
						resp.setMsg(RespStatus.DATABASE_ERROR.getMsg());
						status = LocalStatus.IN_DATABASE_FAIL.getCode();
					}
				} else {
					status = LocalStatus.CALL_SUCCESS.getCode();
					resp.setCode(RespStatus.REQ_ERROR.getCode());
					resp.setMsg("调用百融接口,返回错误码：" + code);
				}
			} else {
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
		}
		saveDataQueryLogNew(serialNum, loanId, "", loginFacilityInformation.getSwift_number(), sTime,
				ThirdMethodConstants.BR0007, code, status, "edc_br_data_query_log", "");
		return resp;
	}

	@Override
	public ApiResponse<CurrentEquipmentInformationReport> cashFacilityInformationReport(JSONObject json,
			String serialNum, String loanId, String channel) {
		ApiResponse<CurrentEquipmentInformationReport> resp = new ApiResponse<CurrentEquipmentInformationReport>();
		/*
		 * 如果接口停用，直接返回（视具体情况，有的返回停用，有的返回相关值） ADD BY TUXU 2018-05-31
		 */
		if (PropertiesUtils.isTurnOffForSwitch("switch.br0008")) {
			// RespStatus.DISABLE只有接口停用时才使用定义的这个参数，其它情况按原本的来
			resp.setCode(RespStatus.DISABLE.getCode());
			resp.setMsg(RespStatus.DISABLE.getMsg());
			return resp;
		}
		ThirdProperties thirdProperties = ThirdPropertiesInitUtil.getThirdProperties();
		String tokenId = platLogin();
		String mobile = JSONArray.fromObject(json.get("cell")).getString(0);
		CurrentEquipmentInformationReport currentEquipmentInformationReport = new CurrentEquipmentInformationReport();
		Date sTime = new Date();
		serialNum = serialNum + mobile;
		String result = "";
		String code = "";
		String status = LocalStatus.REQUEST_FAIL.getCode();
		if (StringUtils.isEmpty(tokenId)) {
			resp.setCode(RespStatus.REQ_ERROR.getCode());
			resp.setMsg(RespStatus.REQ_ERROR.getMsg());
		} else {

			try {

				result = BaiRongUtil.urlConnectPost(thirdProperties.getBr_packetRequestUrl(),
						"tokenid=" + tokenId + "&apiCode=" + thirdProperties.getBr_apiCode() + "&jsonData="
								+ URLEncoder.encode(json.toString(), "utf-8") + "&checkCode="
								+ BaiRongUtil.getCheckData(json.toString(), thirdProperties.getBr_apiCode(), tokenId));
//				result = BaiRongUtil.urlConnectPost("https://sandbox-api.100credit.cn/bankServer2/data/terData.action",
//						"tokenid=" + tokenId + "&apiCode=" + thirdProperties.getBr_apiCode() + "&jsonData="
//								+ URLEncoder.encode(json.toString(), "utf-8") + "&checkCode="
//								+ BaiRongUtil.getCheckData(json.toString(), thirdProperties.getBr_apiCode(), tokenId));
			} catch (Exception e) {
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
				MarvelsLogUtil.getInstance().error(">>>>>>>>>百融提现设备信息请求:", e);
			}
			MarvelsLogUtil.getInstance().info("==============>>>>百融提现设备信息返回信息:" + result);
			if (StringUtils.isNotEmpty(result)) {
				status = LocalStatus.IN_DATABASE_FAIL.getCode();
				currentEquipmentInformationReport = JSON.parseObject(result, CurrentEquipmentInformationReport.class);
				JSONObject resultJson = new JSONObject();
				resultJson = JSONObject.fromObject(result);
				code = resultJson.get("code").toString();
				if (code.equals("00") || code.equals("100002")) {
					if (code.equals("00")) {
						status = LocalStatus.SUCCESS_WITH_DATA.getCode();
					} else {
						status = LocalStatus.SUCCESS_WITHOUT_DATA.getCode();
					}
					resp.setCode(RespStatus.SUCCESS.getCode());
					resp.setMsg(RespStatus.SUCCESS.getMsg());
					resp.setData(currentEquipmentInformationReport);
					// 数据落地
					try {
						dGBaiRongService.cashFacilityInformationReport(currentEquipmentInformationReport, serialNum,
								loanId, mobile);
					} catch (Exception e) {
						resp.setCode(RespStatus.DATABASE_ERROR.getCode());
						resp.setMsg(RespStatus.DATABASE_ERROR.getMsg());
						status = LocalStatus.IN_DATABASE_FAIL.getCode();
						MarvelsLogUtil.getInstance().error(">>>>>>>>>>>>百融提现设备信息数据落地失败：" + e);
					}
				} else {
					status = LocalStatus.CALL_SUCCESS.getCode();
					resp.setCode(RespStatus.REQ_ERROR.getCode());
					resp.setMsg("调用百融接口,返回错误码：" + code);
				}
			} else {
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
		}
		saveDataQueryLogNew(serialNum, loanId, "", currentEquipmentInformationReport.getSwift_number(), sTime,
				ThirdMethodConstants.BR0008, code, status, "edc_br_data_query_log", "");
		return resp;
	}

	@Override
	public ApiResponse<DishonestExecutor> dishonestExecutorReport(JSONObject json, String serialNum, String loanId,
			String channel) {

		ApiResponse<DishonestExecutor> resp = new ApiResponse<DishonestExecutor>();
		/*
		 * 如果接口停用，直接返回（视具体情况，有的返回停用，有的返回相关值） ADD BY TUXU 2018-05-31
		 */
		if (PropertiesUtils.isTurnOffForSwitch("switch.br0009")) {
			// RespStatus.DISABLE只有接口停用时才使用定义的这个参数，其它情况按原本的来
			resp.setCode(RespStatus.DISABLE.getCode());
			resp.setMsg(RespStatus.DISABLE.getMsg());
			return resp;
		}
		ThirdProperties thirdProperties = ThirdPropertiesInitUtil.getThirdProperties();
		DishonestExecutor dishonestExecutor = new DishonestExecutor();
		String result = "";
		Date sTime = new Date();
		String status = LocalStatus.REQUEST_FAIL.getCode();
		String tokenId = platLogin();
		if (StringUtils.isEmpty(tokenId)) {
			resp.setCode(RespStatus.REQ_ERROR.getCode());
			resp.setMsg(RespStatus.REQ_ERROR.getMsg());
		} else {
			try {

				result = BaiRongUtil.urlConnectPost(thirdProperties.getBr_packetRequestUrl(),
						"tokenid=" + tokenId + "&apiCode=" + thirdProperties.getBr_apiCode() + "&jsonData="
								+ URLEncoder.encode(json.toString(), "utf-8") + "&checkCode="
								+ BaiRongUtil.getCheckData(json.toString(), thirdProperties.getBr_apiCode(), tokenId));
				MarvelsLogUtil.getInstance().info("获取被执行人的执行案件信息(个人)返回信息:" + result);
				if (StringUtils.isNotEmpty(result)) {
					dishonestExecutor = JSON.parseObject(result, DishonestExecutor.class);
					resp.setCode(RespStatus.SUCCESS.getCode());
					resp.setMsg(RespStatus.SUCCESS.getMsg());
					resp.setData(dishonestExecutor);
					status = LocalStatus.SUCCESS_WITH_DATA.getCode();
				} else {
					resp.setCode(RespStatus.REQ_ERROR.getCode());
					resp.setMsg(RespStatus.REQ_ERROR.getMsg());
				}
			} catch (Exception e) {
				MarvelsLogUtil.getInstance().error("获取被执行人的执行案件信息异常", e);
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
		}
		saveDataQueryLogNew(serialNum, loanId, "", dishonestExecutor.getSwift_number(), sTime,
				ThirdMethodConstants.BR0009, dishonestExecutor.getCode(), status, "edc_br_data_query_log", "");
		return resp;
	}

	@Override
	public ApiResponse<DishonestEnterprise> dishonestEnterpriseReport(JSONObject json, String serialNum, String loanId,
			String channel) {

		ApiResponse<DishonestEnterprise> resp = new ApiResponse<DishonestEnterprise>();
		/*
		 * 如果接口停用，直接返回（视具体情况，有的返回停用，有的返回相关值） ADD BY TUXU 2018-05-31
		 */
		if (PropertiesUtils.isTurnOffForSwitch("switch.br0010")) {
			// RespStatus.DISABLE只有接口停用时才使用定义的这个参数，其它情况按原本的来
			resp.setCode(RespStatus.DISABLE.getCode());
			resp.setMsg(RespStatus.DISABLE.getMsg());
			return resp;
		}
		ThirdProperties thirdProperties = ThirdPropertiesInitUtil.getThirdProperties();
		DishonestEnterprise dishonestEnterprise = new DishonestEnterprise();
		String result = "";
		Date sTime = new Date();
		String tokenId = platLogin();
		String status = LocalStatus.REQUEST_FAIL.getCode();
		if (StringUtils.isEmpty(tokenId)) {

			resp.setCode(RespStatus.REQ_ERROR.getCode());
			resp.setMsg(RespStatus.REQ_ERROR.getMsg());
		} else {
			try {

				result = BaiRongUtil.urlConnectPost(thirdProperties.getBr_reportRequestUrl(),
						"tokenid=" + tokenId + "&apiCode=" + thirdProperties.getBr_apiCode() + "&jsonData="
								+ URLEncoder.encode(json.toString(), "utf-8") + "&checkCode="
								+ BaiRongUtil.getCheckData(json.toString(), thirdProperties.getBr_apiCode(), tokenId));
				MarvelsLogUtil.getInstance().info("获取被执行人的执行案件信息(企业)返回信息:" + result);
				if (StringUtils.isNotEmpty(result)) {
					dishonestEnterprise = JSON.parseObject(result, DishonestEnterprise.class);
					resp.setCode(RespStatus.SUCCESS.getCode());
					resp.setMsg(RespStatus.SUCCESS.getMsg());
					resp.setData(dishonestEnterprise);
					status = LocalStatus.SUCCESS_WITH_DATA.getCode();
				} else {
					resp.setCode(RespStatus.REQ_ERROR.getCode());
					resp.setMsg(RespStatus.REQ_ERROR.getMsg());
				}
			} catch (Exception e) {
				MarvelsLogUtil.getInstance().error("获取被执行人的执行案件信息(企业)异常", e);
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
		}
		saveDataQueryLogNew(serialNum, loanId, "", dishonestEnterprise.getSwift_number(), sTime, 
				ThirdMethodConstants.BR0010, dishonestEnterprise.getCode(), status, "edc_br_data_query_log", "");
		return resp;
	}

	@Override
	public ApiResponse<BadInformation> badInformationReport(JSONObject json, String serialNum, String loanId,
			String channel) {
		ApiResponse<BadInformation> resp = new ApiResponse<BadInformation>();
		/*
		 * 如果接口停用，直接返回（视具体情况，有的返回停用，有的返回相关值） ADD BY TUXU 2018-05-31
		 */
		if (PropertiesUtils.isTurnOffForSwitch("switch.br0011")) {
			// RespStatus.DISABLE只有接口停用时才使用定义的这个参数，其它情况按原本的来
			resp.setCode(RespStatus.DISABLE.getCode());
			resp.setMsg(RespStatus.DISABLE.getMsg());
			return resp;
		}
		ThirdProperties thirdProperties = ThirdPropertiesInitUtil.getThirdProperties();
		BadInformation badInformation = new BadInformation();
		String result = "";
		Date sTime = new Date();
		String tokenId = platLogin();
		String status = LocalStatus.REQUEST_FAIL.getCode();
		if (StringUtils.isEmpty(tokenId)) {
			resp.setCode(RespStatus.REQ_ERROR.getCode());
			resp.setMsg(RespStatus.REQ_ERROR.getMsg());
		} else {
			try {

				result = BaiRongUtil.urlConnectPost(thirdProperties.getBr_reportRequestUrl(),
						"tokenid=" + tokenId + "&apiCode=" + thirdProperties.getBr_apiCode() + "&jsonData="
								+ URLEncoder.encode(json.toString(), "utf-8") + "&checkCode="
								+ BaiRongUtil.getCheckData(json.toString(), thirdProperties.getBr_apiCode(), tokenId));
				MarvelsLogUtil.getInstance().info("获取个人不良信息返回:" + result);
				if (StringUtils.isNotEmpty(result)) {
					badInformation = JSON.parseObject(result, BadInformation.class);
					resp.setCode(RespStatus.SUCCESS.getCode());
					resp.setMsg(RespStatus.SUCCESS.getMsg());
					resp.setData(badInformation);
					status = LocalStatus.SUCCESS_WITH_DATA.getCode();
				} else {
					resp.setCode(RespStatus.REQ_ERROR.getCode());
					resp.setMsg(RespStatus.REQ_ERROR.getMsg());
				}
			} catch (Exception e) {
				MarvelsLogUtil.getInstance().error("获取个人不良信息异常", e);
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
		}
		saveDataQueryLogNew(serialNum, loanId, "", badInformation.getSwift_number(), sTime,
				ThirdMethodConstants.BR0011, badInformation.getCode() + "", status, "edc_br_data_query_log", null);
		return resp;
	}

	@Override
	public ApiResponse<TelTwoInformation> telTwoInformationReport(JSONObject json, String serialNum, String loanId,
			String channel) {
		ApiResponse<TelTwoInformation> resp = new ApiResponse<TelTwoInformation>();
		/*
		 * 如果接口停用，直接返回（视具体情况，有的返回停用，有的返回相关值） ADD BY TUXU 2018-05-31
		 */
		if (PropertiesUtils.isTurnOffForSwitch("switch.br0012")) {
			// RespStatus.DISABLE只有接口停用时才使用定义的这个参数，其它情况按原本的来
			resp.setCode(RespStatus.DISABLE.getCode());
			resp.setMsg(RespStatus.DISABLE.getMsg());
			return resp;
		}
		ThirdProperties thirdProperties = ThirdPropertiesInitUtil.getThirdProperties();
		Date sTime = new Date();
		TelTwoInformation telTwoInformation = new TelTwoInformation();
		String result = "";
		String status = LocalStatus.REQUEST_FAIL.getCode();
		String tokenId = platLogin();
		if (StringUtils.isEmpty(tokenId)) {

			resp.setCode(RespStatus.REQ_ERROR.getCode());
			resp.setMsg(RespStatus.REQ_ERROR.getMsg());
		} else {
			try {

				result = BaiRongUtil.urlConnectPost(thirdProperties.getBr_reportRequestUrl(),
						"tokenid=" + tokenId + "&apiCode=" + thirdProperties.getBr_apiCode() + "&jsonData="
								+ URLEncoder.encode(json.toString(), "utf-8") + "&checkCode="
								+ BaiRongUtil.getCheckData(json.toString(), thirdProperties.getBr_apiCode(), tokenId));
				MarvelsLogUtil.getInstance().info("获取手机二要素报告返回信息:" + result);
				if (StringUtils.isNotEmpty(result)) {
					telTwoInformation = JSON.parseObject(result, TelTwoInformation.class);
					resp.setCode(RespStatus.SUCCESS.getCode());
					resp.setMsg(RespStatus.SUCCESS.getMsg());
					resp.setData(telTwoInformation);
					status = LocalStatus.SUCCESS_WITH_DATA.getCode();
				} else {
					resp.setCode(RespStatus.REQ_ERROR.getCode());
					resp.setMsg(RespStatus.REQ_ERROR.getMsg());
				}
			} catch (Exception e) {
				MarvelsLogUtil.getInstance().error("获取手机二要素报告异常", e);
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
		}
		saveDataQueryLogNew(serialNum, loanId, "", telTwoInformation.getSwift_number(), sTime,
				ThirdMethodConstants.BR0012, telTwoInformation.getCode() + "", status, "edc_br_data_query_log", "");
		return resp;
	}

	@Override
	public ApiResponse<TelCheck> telCheckReport(JSONObject json, String serialNum, String loanId, String channel) {

		ApiResponse<TelCheck> resp = new ApiResponse<TelCheck>();
		/*
		 * 如果接口停用，直接返回（视具体情况，有的返回停用，有的返回相关值） ADD BY TUXU 2018-05-31
		 */
		if (PropertiesUtils.isTurnOffForSwitch("switch.br0013")) {
			// RespStatus.DISABLE只有接口停用时才使用定义的这个参数，其它情况按原本的来
			resp.setCode(RespStatus.DISABLE.getCode());
			resp.setMsg(RespStatus.DISABLE.getMsg());
			return resp;
		}
		ThirdProperties thirdProperties = ThirdPropertiesInitUtil.getThirdProperties();
		TelCheck telCheck = new TelCheck();
		String result = "";
		Date sTime = new Date();
		String status = LocalStatus.REQUEST_FAIL.getCode();
		String tokenId = platLogin();
		if (StringUtils.isEmpty(tokenId)) {

			resp.setCode(RespStatus.REQ_ERROR.getCode());
			resp.setMsg(RespStatus.REQ_ERROR.getMsg());
		} else {
			try {

				result = BaiRongUtil.urlConnectPost(thirdProperties.getBr_reportRequestUrl(),
						"tokenid=" + tokenId + "&apiCode=" + thirdProperties.getBr_apiCode() + "&jsonData="
								+ URLEncoder.encode(json.toString(), "utf-8") + "&checkCode="
								+ BaiRongUtil.getCheckData(json.toString(), thirdProperties.getBr_apiCode(), tokenId));
				MarvelsLogUtil.getInstance().info("获取手机三要素报告返回信息:" + result);
				if (StringUtils.isNotEmpty(result)) {
					telCheck = JSON.parseObject(result, TelCheck.class);
					resp.setCode(RespStatus.SUCCESS.getCode());
					resp.setMsg(RespStatus.SUCCESS.getMsg());
					resp.setData(telCheck);
					status = LocalStatus.SUCCESS_WITH_DATA.getCode();
				} else {
					resp.setCode(RespStatus.REQ_ERROR.getCode());
					resp.setMsg(RespStatus.REQ_ERROR.getMsg());
				}
			} catch (Exception e) {
				MarvelsLogUtil.getInstance().error("获取手机三要素报告异常", e);
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
		}
		saveDataQueryLogNew(serialNum, loanId, "", telCheck.getSwift_number(), sTime, 
				ThirdMethodConstants.BR0013, telCheck.getCode() + "", status, "edc_br_data_query_log", "");
		return resp;
	}

	@Override
	public ApiResponse<VehicleViolation> vehicleViolationReport(JSONObject json, String serialNum, String loanId,
			String channel) {

		ApiResponse<VehicleViolation> resp = new ApiResponse<VehicleViolation>();
		/*
		 * 如果接口停用，直接返回（视具体情况，有的返回停用，有的返回相关值） ADD BY TUXU 2018-05-31
		 */
		if (PropertiesUtils.isTurnOffForSwitch("switch.br0014")) {
			// RespStatus.DISABLE只有接口停用时才使用定义的这个参数，其它情况按原本的来
			resp.setCode(RespStatus.DISABLE.getCode());
			resp.setMsg(RespStatus.DISABLE.getMsg());
			return resp;
		}
		ThirdProperties thirdProperties = ThirdPropertiesInitUtil.getThirdProperties();
		VehicleViolation vehicleViolation = new VehicleViolation();
		String result = "";
		Date sTime = new Date();
		String status = LocalStatus.REQUEST_FAIL.getCode();
		String tokenId = platLogin();
		if (StringUtils.isEmpty(tokenId)) {

			resp.setCode(RespStatus.REQ_ERROR.getCode());
			resp.setMsg(RespStatus.REQ_ERROR.getMsg());
		} else {
			try {

				result = BaiRongUtil.urlConnectPost(thirdProperties.getBr_reportRequestUrl(),
						"tokenid=" + tokenId + "&apiCode=" + thirdProperties.getBr_apiCode() + "&jsonData="
								+ URLEncoder.encode(json.toString(), "utf-8") + "&checkCode="
								+ BaiRongUtil.getCheckData(json.toString(), thirdProperties.getBr_apiCode(), tokenId));
				MarvelsLogUtil.getInstance().info("获取车辆违章报告返回信息:" + result);
				if (StringUtils.isNotEmpty(result)) {
					vehicleViolation = JSON.parseObject(result, VehicleViolation.class);
					resp.setCode(RespStatus.SUCCESS.getCode());
					resp.setMsg(RespStatus.SUCCESS.getMsg());
					resp.setData(vehicleViolation);
					status = LocalStatus.SUCCESS_WITH_DATA.getCode();
				} else {
					resp.setCode(RespStatus.REQ_ERROR.getCode());
					resp.setMsg(RespStatus.REQ_ERROR.getMsg());
				}
			} catch (Exception e) {
				MarvelsLogUtil.getInstance().error("获取车辆违章报告异常", e);
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
		}
		saveDataQueryLogNew(serialNum, loanId, "", vehicleViolation.getSwift_number(), sTime,
				ThirdMethodConstants.BR0014, vehicleViolation.getCode() + "", status, "edc_br_data_query_log", "");
		return resp;
	}

	@Override
	public ApiResponse<EductionInformation> eductionInformationReport(JSONObject json, String serialNum, String loanId,
			String channel) {

		ApiResponse<EductionInformation> resp = new ApiResponse<EductionInformation>();
		/*
		 * 如果接口停用，直接返回（视具体情况，有的返回停用，有的返回相关值） ADD BY TUXU 2018-05-31
		 */
		if (PropertiesUtils.isTurnOffForSwitch("switch.br0015")) {
			// RespStatus.DISABLE只有接口停用时才使用定义的这个参数，其它情况按原本的来
			resp.setCode(RespStatus.DISABLE.getCode());
			resp.setMsg(RespStatus.DISABLE.getMsg());
			return resp;
		}
		ThirdProperties thirdProperties = ThirdPropertiesInitUtil.getThirdProperties();
		EductionInformation eductionInformation = new EductionInformation();
		String result = "";
		Date sTime = new Date();
		String status = LocalStatus.REQUEST_FAIL.getCode();
		String tokenId = platLogin();
		if (StringUtils.isEmpty(tokenId)) {

			resp.setCode(RespStatus.REQ_ERROR.getCode());
			resp.setMsg(RespStatus.REQ_ERROR.getMsg());
		} else {
			try {

				result = BaiRongUtil.urlConnectPost(thirdProperties.getBr_reportRequestUrl(),
						"tokenid=" + tokenId + "&apiCode=" + thirdProperties.getBr_apiCode() + "&jsonData="
								+ URLEncoder.encode(json.toString(), "utf-8") + "&checkCode="
								+ BaiRongUtil.getCheckData(json.toString(), thirdProperties.getBr_apiCode(), tokenId));
				MarvelsLogUtil.getInstance().info("获取学历报告返回信息:" + result);
				if (StringUtils.isNotEmpty(result)) {
					eductionInformation = JSON.parseObject(result, EductionInformation.class);
					resp.setCode(RespStatus.SUCCESS.getCode());
					resp.setMsg(RespStatus.SUCCESS.getMsg());
					resp.setData(eductionInformation);
					status = LocalStatus.SUCCESS_WITH_DATA.getCode();

				} else {
					resp.setCode(RespStatus.REQ_ERROR.getCode());
					resp.setMsg(RespStatus.REQ_ERROR.getMsg());
				}
			} catch (Exception e) {
				MarvelsLogUtil.getInstance().error("获取学历报告异常", e);
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
		}
		saveDataQueryLogNew(serialNum, loanId, "", eductionInformation.getSwift_number(), sTime,
				ThirdMethodConstants.BR0015, eductionInformation.getCode() + "", status, "edc_br_data_query_log",
				"");
		return resp;
	}

	@Override
	public ApiResponse<IdCardCheck> idCardCheckReport(JSONObject json, String serialNum, String loanId,
			String channel) {

		ApiResponse<IdCardCheck> resp = new ApiResponse<IdCardCheck>();
		/*
		 * 如果接口停用，直接返回（视具体情况，有的返回停用，有的返回相关值） ADD BY TUXU 2018-05-31
		 */
		if (PropertiesUtils.isTurnOffForSwitch("switch.br0016")) {
			// RespStatus.DISABLE只有接口停用时才使用定义的这个参数，其它情况按原本的来
			resp.setCode(RespStatus.DISABLE.getCode());
			resp.setMsg(RespStatus.DISABLE.getMsg());
			return resp;
		}
		ThirdProperties thirdProperties = ThirdPropertiesInitUtil.getThirdProperties();
		IdCardCheck idCardCheck = new IdCardCheck();
		String result = "";
		Date sTime = new Date();
		String status = LocalStatus.REQUEST_FAIL.getCode();
		String tokenId = platLogin();
		if (tokenId.isEmpty() || tokenId.equals("")) {

			resp.setCode(RespStatus.REQ_ERROR.getCode());
			resp.setMsg(RespStatus.REQ_ERROR.getMsg());
		} else {
			try {

				result = BaiRongUtil.urlConnectPost(thirdProperties.getBr_reportRequestUrl(),
						"tokenid=" + tokenId + "&apiCode=" + thirdProperties.getBr_apiCode() + "&jsonData="
								+ URLEncoder.encode(json.toString(), "utf-8") + "&checkCode="
								+ BaiRongUtil.getCheckData(json.toString(), thirdProperties.getBr_apiCode(), tokenId));
			} catch (Exception e) {

				MarvelsLogUtil.getInstance().error("获取身份证验证报告异常", e);
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
			MarvelsLogUtil.getInstance().info("获取身份证验证报告返回信息:" + result);
			if (StringUtils.isNotEmpty(result)) {
				idCardCheck = JSON.parseObject(result, IdCardCheck.class);
				resp.setCode(RespStatus.SUCCESS.getCode());
				resp.setMsg(RespStatus.SUCCESS.getMsg());
				resp.setData(idCardCheck);
				status = LocalStatus.SUCCESS_WITH_DATA.getCode();
			} else {
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
		}
		saveDataQueryLogNew(serialNum, loanId, "", idCardCheck.getSwift_number(), sTime,
				ThirdMethodConstants.BR0016, idCardCheck.getCode() + "", status, "edc_br_data_query_log", "");
		return resp;
	}

	@Override
	public ApiResponse<BankcardCheck> bankcardCheckReport(JSONObject json, String serialNum, String loanId,
			String channel) {
		ApiResponse<BankcardCheck> resp = new ApiResponse<BankcardCheck>();
		/*
		 * 如果接口停用，直接返回（视具体情况，有的返回停用，有的返回相关值） ADD BY TUXU 2018-05-31
		 */
		if (PropertiesUtils.isTurnOffForSwitch("switch.br0017")) {
			// RespStatus.DISABLE只有接口停用时才使用定义的这个参数，其它情况按原本的来
			resp.setCode(RespStatus.DISABLE.getCode());
			resp.setMsg(RespStatus.DISABLE.getMsg());
			return resp;
		}
		ThirdProperties thirdProperties = ThirdPropertiesInitUtil.getThirdProperties();
		// json.put("apiName", "HainaApi");
		json.put("meal", "BankFourPro");
		BankcardCheck bankcardCheck = new BankcardCheck();
		String result = "";
		String status = LocalStatus.REQUEST_FAIL.getCode();// 请求失败
		Date sTime = new Date();
		String tokenId = platLogin();
		MarvelsLogUtil.getInstance().info("============>>>>百融获取银行卡四要素验证报告请求信息:" + json.toString());
		if (tokenId.isEmpty() || tokenId.equals("")) {
			resp.setCode(RespStatus.REQ_ERROR.getCode());
			resp.setMsg(RespStatus.REQ_ERROR.getMsg());
		} else {
			try {

				result = BaiRongUtil.urlConnectPost(thirdProperties.getBr_reportRequestUrl(),
						"tokenid=" + tokenId + "&apiCode=" + thirdProperties.getBr_apiCode() + "&jsonData="
								+ URLEncoder.encode(json.toString(), "utf-8") + "&checkCode="
								+ BaiRongUtil.getCheckData(json.toString(), thirdProperties.getBr_apiCode(), tokenId));
			} catch (UnsupportedEncodingException e) {
				MarvelsLogUtil.getInstance().error("百融获取银行卡四要素验证报告异常", e);
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}

			if (StringUtils.isNotEmpty(result)) {
				status = LocalStatus.SUCCESS_WITH_DATA.getCode();// 请求成功，且有数据
				MarvelsLogUtil.getInstance().info("============>>>>百融获取银行卡四要素验证报告返回信息:" + result);
				bankcardCheck = JSON.parseObject(result, BankcardCheck.class);
				resp.setCode(RespStatus.SUCCESS.getCode());
				resp.setMsg(RespStatus.SUCCESS.getMsg());
				resp.setData(bankcardCheck);
			} else {
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
		}
		saveDataQueryLogNew(serialNum, loanId, "", bankcardCheck.getSwift_number(), sTime, 
				ThirdMethodConstants.BR0017, bankcardCheck.getCode() + "", status, "edc_br_data_query_log", "");
		return resp;
	}

	@Override
	public ApiResponse<ConsumAbbility> consumAbbilityReport(JSONObject json, String serialNum, String loanId,
			String channel) {
		ApiResponse<ConsumAbbility> resp = new ApiResponse<ConsumAbbility>();
		/*
		 * 如果接口停用，直接返回（视具体情况，有的返回停用，有的返回相关值） ADD BY TUXU 2018-05-31
		 */
		if (PropertiesUtils.isTurnOffForSwitch("switch.br0018")) {
			// RespStatus.DISABLE只有接口停用时才使用定义的这个参数，其它情况按原本的来
			resp.setCode(RespStatus.DISABLE.getCode());
			resp.setMsg(RespStatus.DISABLE.getMsg());
			return resp;
		}
		ThirdProperties thirdProperties = ThirdPropertiesInitUtil.getThirdProperties();
		Date sTime = new Date();
		ConsumAbbility consumAbbility = new ConsumAbbility();
		String result = "";
		String status = LocalStatus.REQUEST_FAIL.getCode();// 请求失败
		String tokenId = platLogin();
		if (tokenId.isEmpty() || tokenId.equals("")) {

			resp.setCode(RespStatus.REQ_ERROR.getCode());
			resp.setMsg(RespStatus.REQ_ERROR.getMsg());
		} else {
			try {

				result = BaiRongUtil.urlConnectPost(thirdProperties.getBr_packetRequestUrl(),
						"tokenid=" + tokenId + "&apiCode=" + thirdProperties.getBr_apiCode() + "&jsonData="
								+ URLEncoder.encode(json.toString(), "utf-8") + "&checkCode="
								+ BaiRongUtil.getCheckData(json.toString(), thirdProperties.getBr_apiCode(), tokenId));
			} catch (UnsupportedEncodingException e) {
				MarvelsLogUtil.getInstance().error("获取消费能力评估异常", e);
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
				e.printStackTrace();
			}

			if (StringUtils.isNotEmpty(result)) {
				status = LocalStatus.SUCCESS_WITH_DATA.getCode();// 请求成功，且有数据
				MarvelsLogUtil.getInstance().info("获取消费能力评估返回信息:" + result);
				consumAbbility = JSON.parseObject(result, ConsumAbbility.class);
				resp.setCode(RespStatus.SUCCESS.getCode());
				resp.setMsg(RespStatus.SUCCESS.getMsg());
				resp.setData(consumAbbility);
			} else {
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
		}
		saveDataQueryLogNew(serialNum, loanId, "", consumAbbility.getSwift_number(), sTime,
				ThirdMethodConstants.BR0018, consumAbbility.getCode() + "", status, "edc_br_data_query_log", "");
		return resp;
	}

	@Override
	public ApiResponse<MediaReading> mediaReadingReport(JSONObject json, String serialNum, String loanId,
			String channel) {

		ApiResponse<MediaReading> resp = new ApiResponse<MediaReading>();
		/*
		 * 如果接口停用，直接返回（视具体情况，有的返回停用，有的返回相关值） ADD BY TUXU 2018-05-31
		 */
		if (PropertiesUtils.isTurnOffForSwitch("switch.br0019")) {
			// RespStatus.DISABLE只有接口停用时才使用定义的这个参数，其它情况按原本的来
			resp.setCode(RespStatus.DISABLE.getCode());
			resp.setMsg(RespStatus.DISABLE.getMsg());
			return resp;
		}
		ThirdProperties thirdProperties = ThirdPropertiesInitUtil.getThirdProperties();
		MediaReading mediaReading = new MediaReading();
		String result = "";
		String status = LocalStatus.REQUEST_FAIL.getCode();// 请求失败
		Date sTime = new Date();
		String tokenId = platLogin();
		if (tokenId.isEmpty() || tokenId.equals("")) {

			resp.setCode(RespStatus.REQ_ERROR.getCode());
			resp.setMsg(RespStatus.REQ_ERROR.getMsg());
		} else {
			try {

				result = BaiRongUtil.urlConnectPost(thirdProperties.getBr_packetRequestUrl(),
						"tokenid=" + tokenId + "&apiCode=" + thirdProperties.getBr_apiCode() + "&jsonData="
								+ URLEncoder.encode(json.toString(), "utf-8") + "&checkCode="
								+ BaiRongUtil.getCheckData(json.toString(), thirdProperties.getBr_apiCode(), tokenId));
			} catch (UnsupportedEncodingException e) {
				MarvelsLogUtil.getInstance().error("获取媒体阅览评估异常", e);
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
				e.printStackTrace();
			}

			if (StringUtils.isNotEmpty(result)) {
				status = LocalStatus.SUCCESS_WITH_DATA.getCode();// 请求成功，且有数据
				MarvelsLogUtil.getInstance().info("获取媒体阅览评估返回信息:" + result);
				mediaReading = JSON.parseObject(result, MediaReading.class);
				resp.setCode(RespStatus.SUCCESS.getCode());
				resp.setMsg(RespStatus.SUCCESS.getMsg());
				resp.setData(mediaReading);
			} else {
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
		}
		Date eTime = new Date();
		if (resp.getCode() != RespStatus.SUCCESS.getCode()) {

			saveErrorLog(serialNum, Integer.toString(resp.getCode()), resp.getMsg(), json.toString(), result, channel,
					ThirdMethodConstants.BR0019, sTime, eTime);
		}
		saveLog(serialNum, Integer.toString(resp.getCode()), resp.getMsg(), json.toString(), result, channel,
				ThirdMethodConstants.BR0019, sTime, eTime, mediaReading.getSwift_number(), "");

		String resultLog = "";
		if (resp.getCode() == RespStatus.SUCCESS.getCode() || resp.getCode() == RespStatus.DATABASE_ERROR.getCode()) {
			resultLog = "1";
		} else if (resp.getCode() == RespStatus.NODATA.getCode()) {
			resultLog = "0";
		} else {
			resultLog = "-1";
		}
		saveCallCountLog(loanId, ThirdMethodConstants.BR0019, resultLog, ThirdProductChannelConstant.BAIRONG.getCode(),
				"媒体阅览评估(媒体阅览评估产品查询用户媒体阅览行为，是对阅览天数、类别等维度的统计评估)");
		saveDataQueryLogNew(serialNum, loanId, "", mediaReading.getSwift_number(), sTime,
				ThirdMethodConstants.BR0019, mediaReading.getCode() + "", status, "edc_br_data_query_log", "");
		return resp;
	}

	@Override
	public ApiResponse<ReceiveAndConsumLevel> receiveAndConsumLevelReport(JSONObject json, String serialNum,
			String loanId, String channel) {
		ApiResponse<ReceiveAndConsumLevel> resp = new ApiResponse<ReceiveAndConsumLevel>();
		/*
		 * 如果接口停用，直接返回（视具体情况，有的返回停用，有的返回相关值） ADD BY TUXU 2018-05-31
		 */
		if (PropertiesUtils.isTurnOffForSwitch("switch.br0020")) {
			// RespStatus.DISABLE只有接口停用时才使用定义的这个参数，其它情况按原本的来
			resp.setCode(RespStatus.DISABLE.getCode());
			resp.setMsg(RespStatus.DISABLE.getMsg());
			return resp;
		}
		ThirdProperties thirdProperties = ThirdPropertiesInitUtil.getThirdProperties();
		ReceiveAndConsumLevel receiveAndConsum = new ReceiveAndConsumLevel();
		Date sTime = new Date();
		String result = "";
		String status = LocalStatus.REQUEST_FAIL.getCode();// 请求失败
		String tokenId = platLogin();
		if (tokenId.isEmpty() || tokenId.equals("")) {

			resp.setCode(RespStatus.REQ_ERROR.getCode());
			resp.setMsg(RespStatus.REQ_ERROR.getMsg());
		} else {
			try {

				result = BaiRongUtil.urlConnectPost(thirdProperties.getBr_packetRequestUrl(),
						"tokenid=" + tokenId + "&apiCode=" + thirdProperties.getBr_apiCode() + "&jsonData="
								+ URLEncoder.encode(json.toString(), "utf-8") + "&checkCode="
								+ BaiRongUtil.getCheckData(json.toString(), thirdProperties.getBr_apiCode(), tokenId));
			} catch (UnsupportedEncodingException e) {
				MarvelsLogUtil.getInstance().error("获取月度收支等级评估异常", e);
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}

			if (StringUtils.isNotEmpty(result)) {
				status = LocalStatus.SUCCESS_WITH_DATA.getCode();// 请求成功，且有数据
				MarvelsLogUtil.getInstance().info("获取月度收支等级评估返回信息:" + result);
				receiveAndConsum = JSON.parseObject(result, ReceiveAndConsumLevel.class);
				resp.setCode(RespStatus.SUCCESS.getCode());
				resp.setMsg(RespStatus.SUCCESS.getMsg());
				resp.setData(receiveAndConsum);
			} else {
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
		}
		Date eTime = new Date();
		if (resp.getCode() != RespStatus.SUCCESS.getCode()) {

			saveErrorLog(serialNum, Integer.toString(resp.getCode()), resp.getMsg(), json.toString(), result, channel,
					ThirdMethodConstants.BR0020, sTime, eTime);
		}
		saveLog(serialNum, Integer.toString(resp.getCode()), resp.getMsg(), json.toString(), result, channel,
				ThirdMethodConstants.BR0020, sTime, eTime, receiveAndConsum.getSwift_number(), "");

		String resultLog = "";
		if (resp.getCode() == RespStatus.SUCCESS.getCode() || resp.getCode() == RespStatus.DATABASE_ERROR.getCode()) {
			resultLog = "1";
		} else if (resp.getCode() == RespStatus.NODATA.getCode()) {
			resultLog = "0";
		} else {
			resultLog = "-1";
		}
		saveCallCountLog(loanId, ThirdMethodConstants.BR0020, resultLog, ThirdProductChannelConstant.BAIRONG.getCode(),
				"月度收支等级评估整合版(月度收支等级评估整合版产品是对用户入账和出账情况的统计");
		saveDataQueryLogNew(serialNum, loanId, "", receiveAndConsum.getSwift_number(), sTime,
				ThirdMethodConstants.BR0020, receiveAndConsum.getCode() + "", status, "edc_br_data_query_log", "");
		return resp;
	}

	@Override
	public ApiResponse<MicroCreditLevel> microCreditLevelReport(JSONObject json, String serialNum, String loanId,
			String channel) {

		ApiResponse<MicroCreditLevel> resp = new ApiResponse<MicroCreditLevel>();
		/*
		 * 如果接口停用，直接返回（视具体情况，有的返回停用，有的返回相关值） ADD BY TUXU 2018-05-31
		 */
		if (PropertiesUtils.isTurnOffForSwitch("switch.br0021")) {
			// RespStatus.DISABLE只有接口停用时才使用定义的这个参数，其它情况按原本的来
			resp.setCode(RespStatus.DISABLE.getCode());
			resp.setMsg(RespStatus.DISABLE.getMsg());
			return resp;
		}
		ThirdProperties thirdProperties = ThirdPropertiesInitUtil.getThirdProperties();
		MicroCreditLevel microCreditLevel = new MicroCreditLevel();
		String result = "";
		String status = LocalStatus.REQUEST_FAIL.getCode();// 请求失败
		Date sTime = new Date();
		String tokenId = platLogin();
		if (tokenId.isEmpty() || tokenId.equals("")) {

			resp.setCode(RespStatus.REQ_ERROR.getCode());
			resp.setMsg(RespStatus.REQ_ERROR.getMsg());
		} else {
			try {

				result = BaiRongUtil.urlConnectPost(thirdProperties.getBr_packetRequestUrl(),
						"tokenid=" + tokenId + "&apiCode=" + thirdProperties.getBr_apiCode() + "&jsonData="
								+ URLEncoder.encode(json.toString(), "utf-8") + "&checkCode="
								+ BaiRongUtil.getCheckData(json.toString(), thirdProperties.getBr_apiCode(), tokenId));
			} catch (UnsupportedEncodingException e) {
				MarvelsLogUtil.getInstance().error("获取收支等级小额信贷版评估异常", e);
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}

			if (StringUtils.isNotEmpty(result)) {
				status = LocalStatus.SUCCESS_WITH_DATA.getCode();// 请求成功，且有数据
				MarvelsLogUtil.getInstance().info("获取收支等级小额信贷版评估返回信息:" + result);
				microCreditLevel = JSON.parseObject(result, MicroCreditLevel.class);
				resp.setCode(RespStatus.SUCCESS.getCode());
				resp.setMsg(RespStatus.SUCCESS.getMsg());
				resp.setData(microCreditLevel);
			} else {
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
		}
		saveDataQueryLogNew(serialNum, loanId, "", microCreditLevel.getSwift_number(), sTime,
				ThirdMethodConstants.BR0021, microCreditLevel.getCode() + "", status, "edc_br_data_query_log", "");
		return resp;
	}

	@Override
	public ApiResponse<PaymentConsum> paymentConsumReport(JSONObject json, String serialNum, String loanId,
			String channel) {

		MarvelsLogUtil.getInstance().info(">>>>>>>>>>支付消费请求参数:" + json);
		ApiResponse<PaymentConsum> resp = new ApiResponse<PaymentConsum>();
		/*
		 * 如果接口停用，直接返回（视具体情况，有的返回停用，有的返回相关值） ADD BY TUXU 2018-05-31
		 */
		if (PropertiesUtils.isTurnOffForSwitch("switch.br0022")) {
			// RespStatus.DISABLE只有接口停用时才使用定义的这个参数，其它情况按原本的来
			resp.setCode(RespStatus.DISABLE.getCode());
			resp.setMsg(RespStatus.DISABLE.getMsg());
			return resp;
		}
		ThirdProperties thirdProperties = ThirdPropertiesInitUtil.getThirdProperties();
		PaymentConsum paymentConsum = new PaymentConsum();
		String result = "";
		String status = LocalStatus.REQUEST_FAIL.getCode();
		String code = "";
		Date sTime = new Date();
		String tokenId = platLogin();
		if (tokenId.isEmpty() || tokenId.equals("")) {
			resp.setCode(RespStatus.REQ_ERROR.getCode());
			resp.setMsg(RespStatus.REQ_ERROR.getMsg());
		} else {
			try {

				result = BaiRongUtil.urlConnectPost(thirdProperties.getBr_packetRequestUrl(),
						"tokenid=" + tokenId + "&apiCode=" + thirdProperties.getBr_apiCode() + "&jsonData="
								+ URLEncoder.encode(json.toString(), "utf-8") + "&checkCode="
								+ BaiRongUtil.getCheckData(json.toString(), thirdProperties.getBr_apiCode(), tokenId));
			} catch (UnsupportedEncodingException e) {
				MarvelsLogUtil.getInstance().error(">>>>>>>>>>>>>>>>支付消费请求异常", e);
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
			MarvelsLogUtil.getInstance().info(">>>>>>>>>>支付消费返回参数:" + result);
			if (StringUtils.isNotEmpty(result)) {
				MarvelsLogUtil.getInstance().info("获取支付消费评估返回信息:" + result);
				paymentConsum = JSON.parseObject(result, PaymentConsum.class);
				code = paymentConsum.getCode();
				if (code.equals("00") || code.equals("100002")) {
					if (code.equals("00")) {
						status = LocalStatus.SUCCESS_WITH_DATA.getCode();
					} else {
						status = LocalStatus.SUCCESS_WITHOUT_DATA.getCode();
					}
					// 数据落地
					try {
						dGBaiRongService.occPaymentConsumReport(paymentConsum, serialNum, loanId);
					} catch (Exception e) {
						MarvelsLogUtil.getInstance().error(">>>>>>>>>>支付消费数据落地失败：", e);
						resp.setCode(RespStatus.DATABASE_ERROR.getCode());
						resp.setMsg(RespStatus.DATABASE_ERROR.getMsg());
						status = LocalStatus.IN_DATABASE_FAIL.getCode();
					}
					resp.setCode(RespStatus.SUCCESS.getCode());
					resp.setMsg(RespStatus.SUCCESS.getMsg());
					resp.setData(paymentConsum);
				} else {
					resp.setCode(RespStatus.REQ_ERROR.getCode());
					resp.setMsg("调用百融接口,返回错误码：" + code);
					status = LocalStatus.CALL_SUCCESS.getCode();
				}
			} else {
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
		}
		saveDataQueryLogNew(serialNum, loanId, "", paymentConsum.getSwift_number(), sTime,
				ThirdMethodConstants.BR0022, paymentConsum.getCode() + "", status, "edc_br_data_query_log", "");
		return resp;
	}

	@Override
	public ApiResponse<MicroPaymentConsum> microPaymentConsumReport(JSONObject json, String serialNum, String loanId,
			String channel) {

		ApiResponse<MicroPaymentConsum> resp = new ApiResponse<MicroPaymentConsum>();
		/*
		 * 如果接口停用，直接返回（视具体情况，有的返回停用，有的返回相关值） ADD BY TUXU 2018-05-31
		 */
		if (PropertiesUtils.isTurnOffForSwitch("switch.br0023")) {
			// RespStatus.DISABLE只有接口停用时才使用定义的这个参数，其它情况按原本的来
			resp.setCode(RespStatus.DISABLE.getCode());
			resp.setMsg(RespStatus.DISABLE.getMsg());
			return resp;
		}
		ThirdProperties thirdProperties = ThirdPropertiesInitUtil.getThirdProperties();
		MicroPaymentConsum microPaymentConsum = new MicroPaymentConsum();
		String result = "";
		String status = LocalStatus.REQUEST_FAIL.getCode();
		Date sTime = new Date();
		String tokenId = platLogin();
		if (tokenId.isEmpty() || tokenId.equals("")) {

			resp.setCode(RespStatus.REQ_ERROR.getCode());
			resp.setMsg(RespStatus.REQ_ERROR.getMsg());
		} else {
			try {
				result = BaiRongUtil.urlConnectPost(thirdProperties.getBr_packetRequestUrl(),
						"tokenid=" + tokenId + "&apiCode=" + thirdProperties.getBr_apiCode() + "&jsonData="
								+ URLEncoder.encode(json.toString(), "utf-8") + "&checkCode="
								+ BaiRongUtil.getCheckData(json.toString(), thirdProperties.getBr_apiCode(), tokenId));
			} catch (UnsupportedEncodingException e) {
				MarvelsLogUtil.getInstance().error("获取支付消费小额信贷版评估异常", e);
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}

			if (StringUtils.isNotEmpty(result)) {
				status = LocalStatus.SUCCESS_WITH_DATA.getCode();
				MarvelsLogUtil.getInstance().info("获取支付消费小额信贷版评估返回信息:" + result);
				microPaymentConsum = JSON.parseObject(result, MicroPaymentConsum.class);
				resp.setCode(RespStatus.SUCCESS.getCode());
				resp.setMsg(RespStatus.SUCCESS.getMsg());
				resp.setData(microPaymentConsum);

			} else {
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
		}
		saveDataQueryLogNew(serialNum, loanId, "", microPaymentConsum.getSwift_number(), sTime,
				ThirdMethodConstants.BR0023, microPaymentConsum.getCode() + "", status, "edc_br_data_query_log", "");
		return resp;
	}

	@Override
	public ApiResponse<PayBehavior> payBehaviorReport(JSONObject json, String serialNum, String loanId,
			String channel) {

		ApiResponse<PayBehavior> resp = new ApiResponse<PayBehavior>();
		/*
		 * 如果接口停用，直接返回（视具体情况，有的返回停用，有的返回相关值） ADD BY TUXU 2018-05-31
		 */
		if (PropertiesUtils.isTurnOffForSwitch("switch.br0024")) {
			// RespStatus.DISABLE只有接口停用时才使用定义的这个参数，其它情况按原本的来
			resp.setCode(RespStatus.DISABLE.getCode());
			resp.setMsg(RespStatus.DISABLE.getMsg());
			return resp;
		}
		ThirdProperties thirdProperties = ThirdPropertiesInitUtil.getThirdProperties();
		PayBehavior payBehavior = new PayBehavior();
		String result = "";
		String status = LocalStatus.REQUEST_FAIL.getCode();
		Date sTime = new Date();
		String tokenId = platLogin();
		if (tokenId.isEmpty() || tokenId.equals("")) {
			resp.setCode(RespStatus.REQ_ERROR.getCode());
			resp.setMsg(RespStatus.REQ_ERROR.getMsg());
		} else {
			try {

				result = BaiRongUtil.urlConnectPost(thirdProperties.getBr_reportRequestUrl(),
						"tokenid=" + tokenId + "&apiCode=" + thirdProperties.getBr_apiCode() + "&jsonData="
								+ URLEncoder.encode(json.toString(), "utf-8") + "&checkCode="
								+ BaiRongUtil.getCheckData(json.toString(), thirdProperties.getBr_apiCode(), tokenId));
			} catch (UnsupportedEncodingException e) {
				MarvelsLogUtil.getInstance().error("获取支付消费行为偏好评估异常", e);
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}

			if (StringUtils.isNotEmpty(result)) {
				status = LocalStatus.SUCCESS_WITH_DATA.getCode();
				MarvelsLogUtil.getInstance().info("获取支付消费行为偏好评估返回信息:" + result);
				payBehavior = JSON.parseObject(result, PayBehavior.class);
				resp.setCode(RespStatus.SUCCESS.getCode());
				resp.setMsg(RespStatus.SUCCESS.getMsg());
				resp.setData(payBehavior);
			} else {
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
		}
		saveDataQueryLogNew(serialNum, loanId, "", payBehavior.getSwift_number(), sTime,
				ThirdMethodConstants.BR0024, payBehavior.getCode() + "", status, "edc_br_data_query_log", "");
		return resp;
	}

	@Override
	public ApiResponse<SocietyRelation> societyRelationReport(JSONObject json, String serialNum, String loanId,
			String channel) {

		ApiResponse<SocietyRelation> resp = new ApiResponse<SocietyRelation>();
		/*
		 * 如果接口停用，直接返回（视具体情况，有的返回停用，有的返回相关值） ADD BY TUXU 2018-05-31
		 */
		if (PropertiesUtils.isTurnOffForSwitch("switch.br0025")) {
			// RespStatus.DISABLE只有接口停用时才使用定义的这个参数，其它情况按原本的来
			resp.setCode(RespStatus.DISABLE.getCode());
			resp.setMsg(RespStatus.DISABLE.getMsg());
			return resp;
		}
		ThirdProperties thirdProperties = ThirdPropertiesInitUtil.getThirdProperties();
		SocietyRelation societyRelation = new SocietyRelation();
		String result = "";
		String status = LocalStatus.REQUEST_FAIL.getCode();
		Date sTime = new Date();
		String tokenId = platLogin();
		if (tokenId.isEmpty() || tokenId.equals("")) {

			resp.setCode(RespStatus.REQ_ERROR.getCode());
			resp.setMsg(RespStatus.REQ_ERROR.getMsg());
		} else {
			try {

				result = BaiRongUtil.urlConnectPost(thirdProperties.getBr_packetRequestUrl(),
						"tokenid=" + tokenId + "&apiCode=" + thirdProperties.getBr_apiCode() + "&jsonData="
								+ URLEncoder.encode(json.toString(), "utf-8") + "&checkCode="
								+ BaiRongUtil.getCheckData(json.toString(), thirdProperties.getBr_apiCode(), tokenId));
			} catch (UnsupportedEncodingException e) {
				MarvelsLogUtil.getInstance().error("获取社交关系评估异常", e);
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}

			if (StringUtils.isNotEmpty(result)) {
				status = LocalStatus.SUCCESS_WITH_DATA.getCode();
				MarvelsLogUtil.getInstance().info("获取社交关系评估返回信息:" + result);
				societyRelation = JSON.parseObject(result, SocietyRelation.class);
				resp.setCode(RespStatus.SUCCESS.getCode());
				resp.setMsg(RespStatus.SUCCESS.getMsg());
				resp.setData(societyRelation);
			} else {
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
		}
		saveDataQueryLogNew(serialNum, loanId, "", societyRelation.getSwift_number(), sTime,
				ThirdMethodConstants.BR0025, societyRelation.getCode() + "", status, "edc_br_data_query_log", "");
		return resp;
	}
	
	@Override
	public ApiResponse<AirTravelLevel> airTravelLevelReport(JSONObject json, String serialNum, String loanId,
			String channel) {

		ApiResponse<AirTravelLevel> resp = new ApiResponse<AirTravelLevel>();
		/*
		 * 如果接口停用，直接返回（视具体情况，有的返回停用，有的返回相关值） ADD BY TUXU 2018-05-31
		 */
		if (PropertiesUtils.isTurnOffForSwitch("switch.br0026")) {
			// RespStatus.DISABLE只有接口停用时才使用定义的这个参数，其它情况按原本的来
			resp.setCode(RespStatus.DISABLE.getCode());
			resp.setMsg(RespStatus.DISABLE.getMsg());
			return resp;
		}
		ThirdProperties thirdProperties = ThirdPropertiesInitUtil.getThirdProperties();
		AirTravelLevel airTravelLevel = new AirTravelLevel();
		String result = "";
		String status = LocalStatus.REQUEST_FAIL.getCode();
		Date sTime = new Date();
		String tokenId = platLogin();
		if (tokenId.isEmpty() || tokenId.equals("")) {

			resp.setCode(RespStatus.REQ_ERROR.getCode());
			resp.setMsg(RespStatus.REQ_ERROR.getMsg());
		} else {
			try {

				result = BaiRongUtil.urlConnectPost(thirdProperties.getBr_reportRequestUrl(),
						"tokenid=" + tokenId + "&apiCode=" + thirdProperties.getBr_apiCode() + "&jsonData="
								+ URLEncoder.encode(json.toString(), "utf-8") + "&checkCode="
								+ BaiRongUtil.getCheckData(json.toString(), thirdProperties.getBr_apiCode(), tokenId));
			} catch (UnsupportedEncodingException e) {
				MarvelsLogUtil.getInstance().error("获取航旅—旅客价值等级报告异常", e);
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}

			if (StringUtils.isNotEmpty(result)) {
				status = LocalStatus.SUCCESS_WITH_DATA.getCode();
				MarvelsLogUtil.getInstance().info("获取航旅—旅客价值等级报告返回信息:" + result);
				airTravelLevel = JSON.parseObject(result, AirTravelLevel.class);
				resp.setCode(RespStatus.SUCCESS.getCode());
				resp.setMsg(RespStatus.SUCCESS.getMsg());
				resp.setData(airTravelLevel);
			} else {
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
		}
		saveDataQueryLogNew(serialNum, loanId, "", airTravelLevel.getSwift_number(), sTime,
				ThirdMethodConstants.BR0026, airTravelLevel.getCode() + "", status, "edc_br_data_query_log", "");
		return resp;
	}

	@Override
	public ApiResponse<TelStatus> telStatusReport(JSONObject json, String serialNum, String loanId, String channel) {

		ApiResponse<TelStatus> resp = new ApiResponse<TelStatus>();
		/*
		 * 如果接口停用，直接返回（视具体情况，有的返回停用，有的返回相关值） ADD BY TUXU 2018-05-31
		 */
		if (PropertiesUtils.isTurnOffForSwitch("switch.br0027")) {
			// RespStatus.DISABLE只有接口停用时才使用定义的这个参数，其它情况按原本的来
			resp.setCode(RespStatus.DISABLE.getCode());
			resp.setMsg(RespStatus.DISABLE.getMsg());
			return resp;
		}
		ThirdProperties thirdProperties = ThirdPropertiesInitUtil.getThirdProperties();
		TelStatus telStatus = new TelStatus();
		String result = "";
		String status = LocalStatus.REQUEST_FAIL.getCode();
		Date sTime = new Date();
		String tokenId = platLogin();
		if (tokenId.isEmpty() || tokenId.equals("")) {

			resp.setCode(RespStatus.REQ_ERROR.getCode());
			resp.setMsg(RespStatus.REQ_ERROR.getMsg());
		} else {
			try {

				result = BaiRongUtil.urlConnectPost(thirdProperties.getBr_reportRequestUrl(),
						"tokenid=" + tokenId + "&apiCode=" + thirdProperties.getBr_apiCode() + "&jsonData="
								+ URLEncoder.encode(json.toString(), "utf-8") + "&checkCode="
								+ BaiRongUtil.getCheckData(json.toString(), thirdProperties.getBr_apiCode(), tokenId));
			} catch (UnsupportedEncodingException e) {
				MarvelsLogUtil.getInstance().error("获取手机在网状态异常", e);
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}

			if (StringUtils.isNotEmpty(result)) {
				status = LocalStatus.SUCCESS_WITH_DATA.getCode();
				MarvelsLogUtil.getInstance().info("获取手机在网状态返回信息:" + result);
				telStatus = JSON.parseObject(result, TelStatus.class);
				resp.setCode(RespStatus.SUCCESS.getCode());
				resp.setMsg(RespStatus.SUCCESS.getMsg());
				resp.setData(telStatus);
			} else {
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
		}
		saveDataQueryLogNew(serialNum, loanId, "", telStatus.getSwift_number(), sTime,
				ThirdMethodConstants.BR0027, telStatus.getCode() + "", status, "edc_br_data_query_log", "");
		return resp;
	}

	@Override
	public ApiResponse<PerInvest> perInvestReport(JSONObject json, String serialNum, String loanId, String channel) {

		ApiResponse<PerInvest> resp = new ApiResponse<PerInvest>();
		/*
		 * 如果接口停用，直接返回（视具体情况，有的返回停用，有的返回相关值） ADD BY TUXU 2018-05-31
		 */
		if (PropertiesUtils.isTurnOffForSwitch("switch.br0028")) {
			// RespStatus.DISABLE只有接口停用时才使用定义的这个参数，其它情况按原本的来
			resp.setCode(RespStatus.DISABLE.getCode());
			resp.setMsg(RespStatus.DISABLE.getMsg());
			return resp;
		}
		ThirdProperties thirdProperties = ThirdPropertiesInitUtil.getThirdProperties();
		PerInvest perInvest = new PerInvest();
		String result = "";
		String status = LocalStatus.REQUEST_FAIL.getCode();
		Date sTime = new Date();
		String tokenId = platLogin();
		if (tokenId.isEmpty() || tokenId.equals("")) {

			resp.setCode(RespStatus.REQ_ERROR.getCode());
			resp.setMsg(RespStatus.REQ_ERROR.getMsg());
		} else {
			try {

				result = BaiRongUtil.urlConnectPost(thirdProperties.getBr_reportRequestUrl(),
						"tokenid=" + tokenId + "&apiCode=" + thirdProperties.getBr_apiCode() + "&jsonData="
								+ URLEncoder.encode(json.toString(), "utf-8") + "&checkCode="
								+ BaiRongUtil.getCheckData(json.toString(), thirdProperties.getBr_apiCode(), tokenId));
			} catch (UnsupportedEncodingException e) {
				MarvelsLogUtil.getInstance().error("获取个人对外投资异常", e);
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}

			if (StringUtils.isNotEmpty(result)) {
				status = LocalStatus.SUCCESS_WITH_DATA.getCode();
				MarvelsLogUtil.getInstance().info("获取个人对外投资返回信息:" + result);
				perInvest = JSON.parseObject(result, PerInvest.class);
				resp.setCode(RespStatus.SUCCESS.getCode());
				resp.setMsg(RespStatus.SUCCESS.getMsg());
				resp.setData(perInvest);
			} else {
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
		}
		saveDataQueryLogNew(serialNum, loanId, "", perInvest.getSwift_number(), sTime,
				ThirdMethodConstants.BR0028, perInvest.getCode() + "", status, "edc_br_data_query_log", "");
		return resp;
	}

	@Override
	public ApiResponse<BizInfo> bizInfoReport(JSONObject json, String serialNum, String loanId, String channel) {

		ApiResponse<BizInfo> resp = new ApiResponse<BizInfo>();
		/*
		 * 如果接口停用，直接返回（视具体情况，有的返回停用，有的返回相关值） ADD BY TUXU 2018-05-31
		 */
		if (PropertiesUtils.isTurnOffForSwitch("switch.br0029")) {
			// RespStatus.DISABLE只有接口停用时才使用定义的这个参数，其它情况按原本的来
			resp.setCode(RespStatus.DISABLE.getCode());
			resp.setMsg(RespStatus.DISABLE.getMsg());
			return resp;
		}
		ThirdProperties thirdProperties = ThirdPropertiesInitUtil.getThirdProperties();
		BizInfo bizInfo = new BizInfo();
		String result = "";
		String status = LocalStatus.REQUEST_FAIL.getCode();
		Date sTime = new Date();
		String tokenId = platLogin();
		if (tokenId.isEmpty() || tokenId.equals("")) {
			resp.setCode(RespStatus.REQ_ERROR.getCode());
			resp.setMsg(RespStatus.REQ_ERROR.getMsg());
		} else {
			try {

				result = BaiRongUtil.urlConnectPost(thirdProperties.getBr_reportRequestUrl(),
						"tokenid=" + tokenId + "&apiCode=" + thirdProperties.getBr_apiCode() + "&jsonData="
								+ URLEncoder.encode(json.toString(), "utf-8") + "&checkCode="
								+ BaiRongUtil.getCheckData(json.toString(), thirdProperties.getBr_apiCode(), tokenId));
			} catch (UnsupportedEncodingException e) {
				MarvelsLogUtil.getInstance().error("获取企业基本信息异常", e);
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}

			if (StringUtils.isNotEmpty(result)) {
				status = LocalStatus.SUCCESS_WITH_DATA.getCode();
				MarvelsLogUtil.getInstance().info("获取企业基本信息返回信息:" + result);
				bizInfo = JSON.parseObject(result, BizInfo.class);
				resp.setCode(RespStatus.SUCCESS.getCode());
				resp.setMsg(RespStatus.SUCCESS.getMsg());
				resp.setData(bizInfo);
			} else {
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
		}
		saveDataQueryLogNew(serialNum, loanId, "", bizInfo.getSwift_number(), sTime,
				ThirdMethodConstants.BR0029, bizInfo.getCode() + "", status, "edc_br_data_query_log", "");
		return resp;
	}

	@Override
	public ApiResponse<BizInvest> bizInvestReport(JSONObject json, String serialNum, String loanId, String channel) {

		ApiResponse<BizInvest> resp = new ApiResponse<BizInvest>();
		/*
		 * 如果接口停用，直接返回（视具体情况，有的返回停用，有的返回相关值） ADD BY TUXU 2018-05-31
		 */
		if (PropertiesUtils.isTurnOffForSwitch("switch.br0030")) {
			// RespStatus.DISABLE只有接口停用时才使用定义的这个参数，其它情况按原本的来
			resp.setCode(RespStatus.DISABLE.getCode());
			resp.setMsg(RespStatus.DISABLE.getMsg());
			return resp;
		}
		ThirdProperties thirdProperties = ThirdPropertiesInitUtil.getThirdProperties();
		BizInvest bizInvest = new BizInvest();
		String result = "";
		String status = LocalStatus.REQUEST_FAIL.getCode();
		Date sTime = new Date();
		String tokenId = platLogin();
		if (tokenId.isEmpty() || tokenId.equals("")) {

			resp.setCode(RespStatus.REQ_ERROR.getCode());
			resp.setMsg(RespStatus.REQ_ERROR.getMsg());
		} else {
			try {

				result = BaiRongUtil.urlConnectPost(thirdProperties.getBr_reportRequestUrl(),
						"tokenid=" + tokenId + "&apiCode=" + thirdProperties.getBr_apiCode() + "&jsonData="
								+ URLEncoder.encode(json.toString(), "utf-8") + "&checkCode="
								+ BaiRongUtil.getCheckData(json.toString(), thirdProperties.getBr_apiCode(), tokenId));
			} catch (UnsupportedEncodingException e) {
				MarvelsLogUtil.getInstance().error("获取企业对外投资异常", e);
			}

			if (StringUtils.isNotEmpty(result)) {
				status = LocalStatus.SUCCESS_WITH_DATA.getCode();
				MarvelsLogUtil.getInstance().info("获取企业对外投资返回信息:" + result);
				bizInvest = JSON.parseObject(result, BizInvest.class);
				resp.setCode(RespStatus.SUCCESS.getCode());
				resp.setMsg(RespStatus.SUCCESS.getMsg());
				resp.setData(bizInvest);
			} else {
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
		}
		saveDataQueryLogNew(serialNum, loanId, "", bizInvest.getSwift_number(), sTime,
				ThirdMethodConstants.BR0030, bizInvest.getCode() + "", status, "edc_br_data_query_log", "");
		return resp;
	}

	@Override
	public ApiResponse<BizInfoKey> bizInfoKeyReport(JSONObject json, String serialNum, String loanId, String channel) {
		ApiResponse<BizInfoKey> resp = new ApiResponse<BizInfoKey>();
		/*
		 * 如果接口停用，直接返回（视具体情况，有的返回停用，有的返回相关值） ADD BY TUXU 2018-05-31
		 */
		if (PropertiesUtils.isTurnOffForSwitch("switch.br0031")) {
			// RespStatus.DISABLE只有接口停用时才使用定义的这个参数，其它情况按原本的来
			resp.setCode(RespStatus.DISABLE.getCode());
			resp.setMsg(RespStatus.DISABLE.getMsg());
			return resp;
		}
		ThirdProperties thirdProperties = ThirdPropertiesInitUtil.getThirdProperties();
		Date sTime = new Date();
		BizInfoKey bizInfoKey = new BizInfoKey();
		String result = "";
		String status = LocalStatus.REQUEST_FAIL.getCode();
		String tokenId = platLogin();
		if (tokenId.isEmpty() || tokenId.equals("")) {
			resp.setCode(RespStatus.REQ_ERROR.getCode());
			resp.setMsg(RespStatus.REQ_ERROR.getMsg());
		} else {
			try {

				result = BaiRongUtil.urlConnectPost(thirdProperties.getBr_reportRequestUrl(),
						"tokenid=" + tokenId + "&apiCode=" + thirdProperties.getBr_apiCode() + "&jsonData="
								+ URLEncoder.encode(json.toString(), "utf-8") + "&checkCode="
								+ BaiRongUtil.getCheckData(json.toString(), thirdProperties.getBr_apiCode(), tokenId));
			} catch (UnsupportedEncodingException e) {
				MarvelsLogUtil.getInstance().error("获取企业关键字模糊查询报告异常", e);
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}

			if (StringUtils.isNotEmpty(result)) {
				MarvelsLogUtil.getInstance().info("获取企业关键字模糊查询报告返回信息:" + result);
				status = LocalStatus.SUCCESS_WITH_DATA.getCode();
				bizInfoKey = JSON.parseObject(result, BizInfoKey.class);
				resp.setCode(RespStatus.SUCCESS.getCode());
				resp.setMsg(RespStatus.SUCCESS.getMsg());
				resp.setData(bizInfoKey);
			} else {
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
		}
		saveDataQueryLogNew(serialNum, loanId, "", bizInfoKey.getSwift_number(), sTime,
				ThirdMethodConstants.BR0031, bizInfoKey.getCode() + "", status, "edc_br_data_query_log", "");
		return resp;
	}

	@Override
	public ApiResponse<BizInvestMap> bizInvestMapReport(JSONObject json, String serialNum, String loanId,
			String channel) {

		ApiResponse<BizInvestMap> resp = new ApiResponse<BizInvestMap>();
		/*
		 * 如果接口停用，直接返回（视具体情况，有的返回停用，有的返回相关值） ADD BY TUXU 2018-05-31
		 */
		if (PropertiesUtils.isTurnOffForSwitch("switch.br0032")) {
			// RespStatus.DISABLE只有接口停用时才使用定义的这个参数，其它情况按原本的来
			resp.setCode(RespStatus.DISABLE.getCode());
			resp.setMsg(RespStatus.DISABLE.getMsg());
			return resp;
		}
		ThirdProperties thirdProperties = ThirdPropertiesInitUtil.getThirdProperties();
		BizInvestMap bizInvestMap = new BizInvestMap();
		String result = "";
		String status = LocalStatus.REQUEST_FAIL.getCode();
		Date sTime = new Date();
		String tokenId = platLogin();
		if (tokenId.isEmpty() || tokenId.equals("")) {
			resp.setCode(RespStatus.REQ_ERROR.getCode());
			resp.setMsg(RespStatus.REQ_ERROR.getMsg());
		} else {
			try {

				result = BaiRongUtil.urlConnectPost(thirdProperties.getBr_reportRequestUrl(),
						"tokenid=" + tokenId + "&apiCode=" + thirdProperties.getBr_apiCode() + "&jsonData="
								+ URLEncoder.encode(json.toString(), "utf-8") + "&checkCode="
								+ BaiRongUtil.getCheckData(json.toString(), thirdProperties.getBr_apiCode(), tokenId));
			} catch (UnsupportedEncodingException e) {
				MarvelsLogUtil.getInstance().error("获取企业对外投资图谱报告异常", e);
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}

			if (StringUtils.isNotEmpty(result)) {
				status = LocalStatus.SUCCESS_WITH_DATA.getCode();
				MarvelsLogUtil.getInstance().info("获取企业对外投资图谱报告返回信息:" + result);
				bizInvestMap = JSON.parseObject(result, BizInvestMap.class);
				resp.setCode(RespStatus.SUCCESS.getCode());
				resp.setMsg(RespStatus.SUCCESS.getMsg());
				resp.setData(bizInvestMap);
			} else {
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
		}
		saveDataQueryLogNew(serialNum, loanId, "", bizInvestMap.getSwift_number(), sTime,
				ThirdMethodConstants.BR0032, bizInvestMap.getCode() + "", status, "edc_br_data_query_log", "");
		return resp;
	}

	@Override
	public ApiResponse<Score> scoreReport(JSONObject json, String serialNum, String loanId, String channel) {

		ApiResponse<Score> resp = new ApiResponse<Score>();
		/*
		 * 如果接口停用，直接返回（视具体情况，有的返回停用，有的返回相关值） ADD BY TUXU 2018-05-31
		 */
		if (PropertiesUtils.isTurnOffForSwitch("switch.br0033")) {
			// RespStatus.DISABLE只有接口停用时才使用定义的这个参数，其它情况按原本的来
			resp.setCode(RespStatus.DISABLE.getCode());
			resp.setMsg(RespStatus.DISABLE.getMsg());
			return resp;
		}
		ThirdProperties thirdProperties = ThirdPropertiesInitUtil.getThirdProperties();
		Score score = new Score();
		String result = "";
		String code = "";
		String status = LocalStatus.REQUEST_FAIL.getCode();
		Date sTime = new Date();
		String tokenId = platLogin();
		if (tokenId.isEmpty() || tokenId.equals("")) {

			resp.setCode(RespStatus.REQ_ERROR.getCode());
			resp.setMsg(RespStatus.REQ_ERROR.getMsg());
		} else {
			try {
				result = BaiRongUtil.urlConnectPost(thirdProperties.getBr_packetRequestUrl(),
						"tokenid=" + tokenId + "&apiCode=" + thirdProperties.getBr_apiCode() + "&jsonData="
								+ URLEncoder.encode(json.toString(), "utf-8") + "&checkCode="
								+ BaiRongUtil.getCheckData(json.toString(), thirdProperties.getBr_apiCode(), tokenId));
			} catch (UnsupportedEncodingException e) {
				MarvelsLogUtil.getInstance().error(">>>>>>>>>>百融评分请求异常:", e);
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
			if (StringUtils.isNotEmpty(result)) {
				MarvelsLogUtil.getInstance().info("获取百融评分报告返回信息:" + result);
				JSONObject resultJson = new JSONObject();
				resultJson = JSONObject.fromObject(result);
				code = resultJson.get("code").toString();
				if (code.equals("00") || code.equals("100002")) {
					if (code.equals("00")) {
						status = LocalStatus.SUCCESS_WITH_DATA.getCode();
					} else {
						status = LocalStatus.SUCCESS_WITHOUT_DATA.getCode();
					}
					score = JSON.parseObject(result, Score.class);
					// 数据落地
					try {
						dGBaiRongService.scoreReport(score, serialNum, loanId);
					} catch (Exception e) {
						MarvelsLogUtil.getInstance().error("百融评分落地失败：", e);
						resp.setCode(RespStatus.DATABASE_ERROR.getCode());
						resp.setMsg(RespStatus.DATABASE_ERROR.getMsg());
						status = LocalStatus.IN_DATABASE_FAIL.getCode();
					}
					resp.setCode(RespStatus.SUCCESS.getCode());
					resp.setMsg(RespStatus.SUCCESS.getMsg());
					resp.setData(score);
				} else {
					resp.setCode(RespStatus.REQ_ERROR.getCode());
					resp.setMsg("调用百融接口,返回错误码：" + code);
					status = LocalStatus.CALL_SUCCESS.getCode();
				}
			} else {
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
		}
		saveDataQueryLogNew(serialNum, loanId, "", score.getSwift_number(), sTime,
				ThirdMethodConstants.BR0033, code, status, "edc_br_data_query_log", "");
		return resp;
	}

	@Override
	public ApiResponse<IncomeMonthLevel> incomeMonthLevelReport(JSONObject json, String serialNum, String loanId,
			String channel) {
		ApiResponse<IncomeMonthLevel> resp = new ApiResponse<IncomeMonthLevel>();
		/*
		 * 如果接口停用，直接返回（视具体情况，有的返回停用，有的返回相关值） ADD BY TUXU 2018-05-31
		 */
		if (PropertiesUtils.isTurnOffForSwitch("switch.br0034")) {
			// RespStatus.DISABLE只有接口停用时才使用定义的这个参数，其它情况按原本的来
			resp.setCode(RespStatus.DISABLE.getCode());
			resp.setMsg(RespStatus.DISABLE.getMsg());
			return resp;
		}
		ThirdProperties thirdProperties = ThirdPropertiesInitUtil.getThirdProperties();
		Date sTime = new Date();
		IncomeMonthLevel incomeMonthLevel = new IncomeMonthLevel();
		String tokenId = platLogin();
		String result = "";
		String code = "";
		String status = LocalStatus.REQUEST_FAIL.getCode();
		if (tokenId.isEmpty() || tokenId.equals("")) {
			resp.setCode(RespStatus.REQ_ERROR.getCode());
			resp.setMsg(RespStatus.REQ_ERROR.getMsg());
		} else {

			try {
				result = BaiRongUtil.urlConnectPost(thirdProperties.getBr_packetRequestUrl(),
						"tokenid=" + tokenId + "&apiCode=" + thirdProperties.getBr_apiCode() + "&jsonData="
								+ URLEncoder.encode(json.toString(), "utf-8") + "&checkCode="
								+ BaiRongUtil.getCheckData(json.toString(), thirdProperties.getBr_apiCode(), tokenId));
			} catch (UnsupportedEncodingException e) {
				MarvelsLogUtil.getInstance().error(">>>>>>>>>>>>百融月度收支报告请求异常:", e);
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
			if (StringUtils.isNotEmpty(result)) {
				MarvelsLogUtil.getInstance().info(">>>>>>>>>>>>>>获取月度收支报告返回信息:" + result);
				JSONObject resultJson = new JSONObject();
				resultJson = JSONObject.fromObject(result);
				code = resultJson.get("code").toString();
				if (code.equals("00") || code.equals("100002")) {
					if (code.equals("00")) {
						status = LocalStatus.SUCCESS_WITH_DATA.getCode();
					} else {
						status = LocalStatus.SUCCESS_WITHOUT_DATA.getCode();
					}
					incomeMonthLevel = JSON.parseObject(result, IncomeMonthLevel.class);
					// 数据落地
					try {
						dGBaiRongService.incomeMonthLevelReport(incomeMonthLevel, serialNum, loanId);
					} catch (Exception e) {
						MarvelsLogUtil.getInstance().error(">>>>>>>>获取百融月度收支报告数据落地失败：", e);
						resp.setCode(RespStatus.DATABASE_ERROR.getCode());
						resp.setMsg(RespStatus.DATABASE_ERROR.getMsg());
						status = LocalStatus.IN_DATABASE_FAIL.getCode();
					}
					resp.setCode(RespStatus.SUCCESS.getCode());
					resp.setMsg(RespStatus.SUCCESS.getMsg());
					resp.setData(incomeMonthLevel);
				} else {
					resp.setCode(RespStatus.REQ_ERROR.getCode());
					resp.setMsg("调用百融接口,返回错误码：" + code);
					status = LocalStatus.CALL_SUCCESS.getCode();
				}
			} else {
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
		}
		saveDataQueryLogNew(serialNum, loanId, "", incomeMonthLevel.getSwift_number(), sTime,
				ThirdMethodConstants.BR0034, code, status, "edc_br_data_query_log", "");
		return resp;
	}

	@Override
	public ApiResponse<RuleInformation> ruleReport(JSONObject json, String serialNum, String loanId, String channel) {
		ApiResponse<RuleInformation> resp = new ApiResponse<RuleInformation>();
		/*
		 * 如果接口停用，直接返回（视具体情况，有的返回停用，有的返回相关值） ADD BY TUXU 2018-05-31
		 */
		if (PropertiesUtils.isTurnOffForSwitch("switch.br0035")) {
			// RespStatus.DISABLE只有接口停用时才使用定义的这个参数，其它情况按原本的来
			resp.setCode(RespStatus.DISABLE.getCode());
			resp.setMsg(RespStatus.DISABLE.getMsg());
			return resp;
		}
		ThirdProperties thirdProperties = ThirdPropertiesInitUtil.getThirdProperties();
		Date sTime = new Date();
		String tokenId = platLogin();
		RuleInformation ruleInformation = new RuleInformation();
		String result = "";
		String code = "";
		String status = LocalStatus.REQUEST_FAIL.getCode();
		if (tokenId.isEmpty() || tokenId.equals("")) {

			resp.setCode(RespStatus.REQ_ERROR.getCode());
			resp.setMsg(RespStatus.REQ_ERROR.getMsg());
		} else {
			try {

				result = BaiRongUtil.urlConnectPost(thirdProperties.getBr_packetRequestUrl(),
						"tokenid=" + tokenId + "&apiCode=" + thirdProperties.getBr_apiCode() + "&jsonData="
								+ URLEncoder.encode(json.toString(), "utf-8") + "&checkCode="
								+ BaiRongUtil.getCheckData(json.toString(), thirdProperties.getBr_apiCode(), tokenId));
			} catch (Exception e) {
				MarvelsLogUtil.getInstance().error(">>>>>>>>>调用百融规则请求异常", e);
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
			if (StringUtils.isNotEmpty(result)) {
				MarvelsLogUtil.getInstance().info("获取百融规则报告返回信息:" + result);
				JSONObject resultJson = new JSONObject();
				resultJson = JSONObject.fromObject(result);
				code = resultJson.get("code").toString();
				if (code.equals("00") || code.equals("100002")) {
					if (code.equals("00")) {
						status = LocalStatus.SUCCESS_WITH_DATA.getCode();
					} else {
						status = LocalStatus.SUCCESS_WITHOUT_DATA.getCode();
					}
					ruleInformation = JSON.parseObject(result, RuleInformation.class);
					// 数据落地
					try {
						dGBaiRongService.ruleReport(ruleInformation, serialNum, loanId);
					} catch (Exception e) {
						MarvelsLogUtil.getInstance().error(">>>>>>>调用百融规则数据落地失败：", e);
						resp.setCode(RespStatus.DATABASE_ERROR.getCode());
						resp.setMsg(RespStatus.DATABASE_ERROR.getMsg());
						status = LocalStatus.IN_DATABASE_FAIL.getCode();
					}
					resp.setCode(RespStatus.SUCCESS.getCode());
					resp.setMsg(RespStatus.SUCCESS.getMsg());
					resp.setData(ruleInformation);

				} else {
					resp.setCode(RespStatus.REQ_ERROR.getCode());
					resp.setMsg("调用百融接口,返回错误码：" + code);
					status = LocalStatus.CALL_SUCCESS.getCode();
				}
			} else {
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
		}
		saveDataQueryLogNew(serialNum, loanId, "", ruleInformation.getSwift_number(), sTime, 
				ThirdMethodConstants.BR0035, code, status, "edc_br_data_query_log", "");
		return resp;
	}

	@Override
	public ApiResponse<EquipmentInfor> equipmentInformationVerification(JSONObject json, String serialNum,
			String loanId, String channel) {
		ApiResponse<EquipmentInfor> resp = new ApiResponse<EquipmentInfor>();
		/*
		 * 如果接口停用，直接返回（视具体情况，有的返回停用，有的返回相关值） ADD BY TUXU 2018-05-31
		 */
		if (PropertiesUtils.isTurnOffForSwitch("switch.br0036")) {
			// RespStatus.DISABLE只有接口停用时才使用定义的这个参数，其它情况按原本的来
			resp.setCode(RespStatus.DISABLE.getCode());
			resp.setMsg(RespStatus.DISABLE.getMsg());
			return resp;
		}
		ThirdProperties thirdProperties = ThirdPropertiesInitUtil.getThirdProperties();
		Date sTime = new Date();
		String tokenId = platLogin();
		EquipmentInfor equipmentInfor = new EquipmentInfor();
		String result = "";
		String code = "";
		String status = LocalStatus.REQUEST_FAIL.getCode();
		if (tokenId.isEmpty() || tokenId.equals("")) {
			resp.setCode(RespStatus.REQ_ERROR.getCode());
			resp.setMsg(RespStatus.REQ_ERROR.getMsg());
		} else {
			try {

				result = BaiRongUtil.urlConnectPost(thirdProperties.getBr_packetRequestUrl(),
						"tokenid=" + tokenId + "&apiCode=" + thirdProperties.getBr_apiCode() + "&jsonData="
								+ URLEncoder.encode(json.toString(), "utf-8") + "&checkCode="
								+ BaiRongUtil.getCheckData(json.toString(), thirdProperties.getBr_apiCode(), tokenId));
			} catch (Exception e) {
				MarvelsLogUtil.getInstance().error(">>>>>>>>>>>>>>百融设备信息核查请求异常", e);
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
			if (StringUtils.isNotEmpty(result)) {
				MarvelsLogUtil.getInstance().info("==============>>>>百融设备信息核查返回信息:" + result);
				JSONObject resultJson = new JSONObject();
				resultJson = JSONObject.fromObject(result);
				code = resultJson.get("code").toString();
				if (code.equals("00") || code.equals("100002")) {
					if (code.equals("00")) {
						status = LocalStatus.SUCCESS_WITH_DATA.getCode();
					} else {
						status = LocalStatus.SUCCESS_WITHOUT_DATA.getCode();
					}
					equipmentInfor = JSON.parseObject(result, EquipmentInfor.class);
					resp.setCode(RespStatus.SUCCESS.getCode());
					resp.setMsg(RespStatus.SUCCESS.getMsg());
					resp.setData(equipmentInfor);
					// 数据落地
					try {
						dGBaiRongService.equipmentInformationVerification(equipmentInfor, serialNum, loanId, "","");
					} catch (Exception e) {
						status = LocalStatus.IN_DATABASE_FAIL.getCode();
						MarvelsLogUtil.getInstance().error(">>>>>>>>>>百融设备信息核查数据落地失败：", e);
						resp.setCode(RespStatus.DATABASE_ERROR.getCode());
						resp.setMsg(RespStatus.DATABASE_ERROR.getMsg());
					}
				} else {
					resp.setCode(RespStatus.REQ_ERROR.getCode());
					resp.setMsg("调用百融接口,返回错误码：" + code);
					status = LocalStatus.CALL_SUCCESS.getCode();
				}
			} else {
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
		}
		saveDataQueryLogNew(serialNum, loanId, "", equipmentInfor.getSwift_number(), sTime,
				ThirdMethodConstants.BR0036, code, status, "edc_br_data_query_log", "");
		return resp;
	}

	@Override
	public ApiResponse<EquipmentSpecialList> equipmentSpecialListInfo(JSONObject json, String serialNum, String loanId,
			String channel) {
		ApiResponse<EquipmentSpecialList> resp = new ApiResponse<EquipmentSpecialList>();
		/*
		 * 如果接口停用，直接返回（视具体情况，有的返回停用，有的返回相关值） ADD BY TUXU 2018-05-31
		 */
		if (PropertiesUtils.isTurnOffForSwitch("switch.br0037")) {
			// RespStatus.DISABLE只有接口停用时才使用定义的这个参数，其它情况按原本的来
			resp.setCode(RespStatus.DISABLE.getCode());
			resp.setMsg(RespStatus.DISABLE.getMsg());
			return resp;
		}
		ThirdProperties thirdProperties = ThirdPropertiesInitUtil.getThirdProperties();
		Date sTime = new Date();
		String tokenId = platLogin();
		EquipmentSpecialList equipmentSpecialList = new EquipmentSpecialList();
		String result = "";
		String code = "";
		String status = LocalStatus.REQUEST_FAIL.getCode();
		if (tokenId.isEmpty() || tokenId.equals("")) {
			resp.setCode(RespStatus.REQ_ERROR.getCode());
			resp.setMsg(RespStatus.REQ_ERROR.getMsg());
		} else {

			try {

				result = BaiRongUtil.urlConnectPost(thirdProperties.getBr_packetRequestUrl(),
						"tokenid=" + tokenId + "&apiCode=" + thirdProperties.getBr_apiCode() + "&jsonData="
								+ URLEncoder.encode(json.toString(), "utf-8") + "&checkCode="
								+ BaiRongUtil.getCheckData(json.toString(), thirdProperties.getBr_apiCode(), tokenId));
			} catch (Exception e) {
				MarvelsLogUtil.getInstance().error(">>>>>>>>>>>>>百融设备特殊名单请求异常:", e);
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
			if (StringUtils.isNotEmpty(result)) {
				MarvelsLogUtil.getInstance().info("==============>>>>百融设备特殊名单返回信息:" + result);
				JSONObject resultJson = new JSONObject();
				resultJson = JSONObject.fromObject(result);
				code = resultJson.get("code").toString();
				if (code.equals("00") || code.equals("100002")) {
					if (code.equals("00")) {
						status = LocalStatus.SUCCESS_WITH_DATA.getCode();
					} else {
						status = LocalStatus.SUCCESS_WITHOUT_DATA.getCode();
					}
					equipmentSpecialList = JSON.parseObject(result, EquipmentSpecialList.class);
					resp.setCode(RespStatus.SUCCESS.getCode());
					resp.setMsg(RespStatus.SUCCESS.getMsg());
					resp.setData(equipmentSpecialList);
					// 数据落地
					try {
						dGBaiRongService.equipmentSpecialListInfo(equipmentSpecialList, serialNum, loanId, "","");
					} catch (Exception e) {
						MarvelsLogUtil.getInstance().error(">>>>>>>>>>>百融设备特殊名单落库:", e);
						resp.setCode(RespStatus.DATABASE_ERROR.getCode());
						resp.setMsg(RespStatus.DATABASE_ERROR.getMsg());
						status = LocalStatus.IN_DATABASE_FAIL.getCode();
					}
				} else {
					resp.setCode(RespStatus.REQ_ERROR.getCode());
					resp.setMsg("调用百融接口,返回错误码：" + code);
					status = LocalStatus.CALL_SUCCESS.getCode();
				}
			} else {
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
		}
		saveDataQueryLogNew(serialNum, loanId, "", equipmentSpecialList.getSwift_number(), sTime, 
				ThirdMethodConstants.BR0037, code, status, "edc_br_data_query_log", "");

		return resp;
	}

	@Override
	public ApiResponse<EquipmentInfo> equipmentInfo(JSONObject json, String serialNum, String loanId, String channel) {
		ApiResponse<EquipmentInfo> resp = new ApiResponse<EquipmentInfo>();
		/*
		 * 如果接口停用，直接返回（视具体情况，有的返回停用，有的返回相关值） ADD BY TUXU 2018-05-31
		 */
		if (PropertiesUtils.isTurnOffForSwitch("switch.br0038")) {
			// RespStatus.DISABLE只有接口停用时才使用定义的这个参数，其它情况按原本的来
			resp.setCode(RespStatus.DISABLE.getCode());
			resp.setMsg(RespStatus.DISABLE.getMsg());
			return resp;
		}
		ThirdProperties thirdProperties = ThirdPropertiesInitUtil.getThirdProperties();
		String tokenId = platLogin();
		EquipmentInfo equipmentInfo = new EquipmentInfo();
		String result = "";
		String code = "";
		String status = LocalStatus.REQUEST_FAIL.getCode();
		Date sTime = new Date();
		if (tokenId.isEmpty() || tokenId.equals("")) {

			resp.setCode(RespStatus.REQ_ERROR.getCode());
			resp.setMsg(RespStatus.REQ_ERROR.getMsg());
		} else {

			try {

				result = BaiRongUtil.urlConnectPost(thirdProperties.getBr_packetRequestUrl(),
						"tokenid=" + tokenId + "&apiCode=" + thirdProperties.getBr_apiCode() + "&jsonData="
								+ URLEncoder.encode(json.toString(), "utf-8") + "&checkCode="
								+ BaiRongUtil.getCheckData(json.toString(), thirdProperties.getBr_apiCode(), tokenId));
			} catch (Exception e) {
				MarvelsLogUtil.getInstance().error(">>>>>>>>>>>>>>>>>>设备采集信息请求异常:", e);
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
			if (StringUtils.isNotEmpty(result)) {
				MarvelsLogUtil.getInstance().info("==============>>>>百融设备采集信息返回信息:" + result);
				JSONObject resultJson = new JSONObject();
				resultJson = JSONObject.fromObject(result);
				code = resultJson.get("code").toString();
				if (code.equals("00") || code.equals("100002")) {
					if (code.equals("00")) {
						status = LocalStatus.SUCCESS_WITH_DATA.getCode();
					} else {
						status = LocalStatus.SUCCESS_WITHOUT_DATA.getCode();
					}
					equipmentInfo = JSON.parseObject(result, EquipmentInfo.class);
					resp.setCode(RespStatus.SUCCESS.getCode());
					resp.setMsg(RespStatus.SUCCESS.getMsg());
					resp.setData(equipmentInfo);
					// 数据落地
					try {
						dGBaiRongService.equipmentInfo(equipmentInfo, serialNum, loanId, "","");
					} catch (Exception e) {
						status = LocalStatus.IN_DATABASE_FAIL.getCode();
						MarvelsLogUtil.getInstance().error(">>>>>>>>>>>>百融设备采集信息数据落地失败：" + e);
						resp.setCode(RespStatus.DATABASE_ERROR.getCode());
						resp.setMsg(RespStatus.DATABASE_ERROR.getMsg());
					}
				} else {
					resp.setCode(RespStatus.REQ_ERROR.getCode());
					resp.setMsg("调用百融接口,返回错误码：" + code);
					status = LocalStatus.CALL_SUCCESS.getCode();
				}
			} else {
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
		}
		saveDataQueryLogNew(serialNum, loanId, "", equipmentInfo.getSwift_number(), sTime, 
				ThirdMethodConstants.BR0038, code, status, "edc_br_data_query_log", "");

		return resp;
	}

	@Override
	public ApiResponse<BankcardCheckThree> bankcardCheckThreeReport(JSONObject json, String serialNum, String loanId,
			String channel) {
		ApiResponse<BankcardCheckThree> resp = new ApiResponse<BankcardCheckThree>();
		/*
		 * 如果接口停用，直接返回（视具体情况，有的返回停用，有的返回相关值） ADD BY TUXU 2018-05-31
		 */
		if (PropertiesUtils.isTurnOffForSwitch("switch.br0039")) {
			// RespStatus.DISABLE只有接口停用时才使用定义的这个参数，其它情况按原本的来
			resp.setCode(RespStatus.DISABLE.getCode());
			resp.setMsg(RespStatus.DISABLE.getMsg());
			return resp;
		}
		ThirdProperties thirdProperties = ThirdPropertiesInitUtil.getThirdProperties();
		BankcardCheckThree bankcardCheckThree = new BankcardCheckThree();
		Date sTime = new Date();
		String tokenId = platLogin();
		String result = "";
		String code = "";
		String status = LocalStatus.REQUEST_FAIL.getCode();
		if (tokenId.isEmpty() || tokenId.equals("")) {
			resp.setCode(RespStatus.REQ_ERROR.getCode());
			resp.setMsg(RespStatus.REQ_ERROR.getMsg());
		} else {

			JSONObject jsonObject = new JSONObject();
			// jsonObject.put("apiName", "HainaApi");
			jsonObject.put("meal", "BankThree");
			jsonObject.put("id", json.get("id"));
			jsonObject.put("name", json.get("name"));
			jsonObject.put("bank_id", json.get("bank_id"));
			try {

				result = BaiRongUtil.urlConnectPost(thirdProperties.getBr_reportRequestUrl(), "tokenid=" + tokenId
						+ "&apiCode=" + thirdProperties.getBr_apiCode() + "&jsonData="
						+ URLEncoder.encode(jsonObject.toString(), "utf-8") + "&checkCode="
						+ BaiRongUtil.getCheckData(jsonObject.toString(), thirdProperties.getBr_apiCode(), tokenId));
			} catch (Exception e) {
				MarvelsLogUtil.getInstance().error(">>>>>>>>>>>>百融银行卡三要素信息请求异常:", e);
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
			if (StringUtils.isNotEmpty(result)) {
				MarvelsLogUtil.getInstance().info("==============>>>>百融银行卡三要素信息查询返回信息:" + result);
				JSONObject resultJson = new JSONObject();
				resultJson = JSONObject.fromObject(result);
				code = resultJson.get("code").toString();
				if (code.equals("600000") || code.equals("100002")) {
					status = LocalStatus.SUCCESS_WITH_DATA.getCode();
					bankcardCheckThree = JSON.parseObject(result, BankcardCheckThree.class);
					resp.setCode(RespStatus.SUCCESS.getCode());
					resp.setMsg(RespStatus.SUCCESS.getMsg());
					resp.setData(bankcardCheckThree);
				} else {
					resp.setCode(RespStatus.REQ_ERROR.getCode());
					resp.setMsg("调用百融接口,返回错误码：" + code);
					status = LocalStatus.CALL_SUCCESS.getCode();
				}
			} else {
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());

			}
		}
		saveDataQueryLogNew(serialNum, loanId, "", bankcardCheckThree.getSwift_number(), sTime,
				ThirdMethodConstants.BR0039, code, status, "edc_br_data_query_log", "");
		return resp;
	}

	@Override
	public ApiResponse<Applications> applicationsReport(JSONObject json, String serialNum, String loanId,
			String channel) {
		ApiResponse resp = new ApiResponse();
		/*
		 * 如果接口停用，直接返回（视具体情况，有的返回停用，有的返回相关值） ADD BY TUXU 2018-05-31
		 */
		if (PropertiesUtils.isTurnOffForSwitch("switch.br0042")) {
			// RespStatus.DISABLE只有接口停用时才使用定义的这个参数，其它情况按原本的来
			resp.setCode(RespStatus.DISABLE.getCode());
			resp.setMsg(RespStatus.DISABLE.getMsg());
			return resp;
		}
		ThirdProperties thirdProperties = ThirdPropertiesInitUtil.getThirdProperties();
		OccApplyLoanInfo occApplyLoanInfo = new OccApplyLoanInfo();
		Date sTime = new Date();
		String id = json.get("idNumber").toString();
		String mobile = json.get("mobile").toString();
		String name = json.get("name").toString();
		String tokenId = platLogin();
		String result = "";
		String code = "";
		String status = "";
		if (tokenId.isEmpty() || tokenId.equals("")) {
			resp.setCode(RespStatus.REQ_ERROR.getCode());
			resp.setMsg(RespStatus.REQ_ERROR.getMsg());
		} else {
			JSONObject jsonObject = new JSONObject();
			jsonObject.put("id", id);
			jsonObject.put("meal", "ApplyLoan");
			JSONArray jsonArray = new JSONArray();
			jsonArray.add(mobile);
			jsonObject.put("cell", jsonArray);
			jsonObject.put("name", name);
			jsonObject.put("gid", "");
			try {
				result = BaiRongUtil.urlConnectPost(thirdProperties.getBr_packetRequestUrl(), "tokenid=" + tokenId
						+ "&apiCode=" + thirdProperties.getBr_apiCode() + "&jsonData="
						+ URLEncoder.encode(jsonObject.toString(), "utf-8") + "&checkCode="
						+ BaiRongUtil.getCheckData(jsonObject.toString(), thirdProperties.getBr_apiCode(), tokenId));
			} catch (Exception e) {
				MarvelsLogUtil.getInstance().error(">>>>>>>>>>>多次申请核查请求异常:", e);
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
				status = LocalStatus.REQUEST_FAIL.getCode();
			}
			if (StringUtils.isNotEmpty(result)) {
				MarvelsLogUtil.getInstance().info("==============>>>>百融多次申请核查查询返回信息:" + result);
				JSONObject resultJson = new JSONObject();
				resultJson = JSONObject.fromObject(result);
				code = resultJson.get("code").toString();
				if (code.equals("00") || code.equals("100002")) {
					if (code.equals("00")) {
						status = LocalStatus.SUCCESS_WITH_DATA.getCode();
					} else {
						status = LocalStatus.SUCCESS_WITHOUT_DATA.getCode();
					}
					occApplyLoanInfo = JSON.parseObject(result, OccApplyLoanInfo.class);
					resp.setCode(RespStatus.SUCCESS.getCode());
					resp.setMsg(RespStatus.SUCCESS.getMsg());
					resp.setData(occApplyLoanInfo);
					// 数据落地
					try {
						dGBaiRongService.occApplyLoan(occApplyLoanInfo, serialNum, loanId);
					} catch (Exception e) {
						MarvelsLogUtil.getInstance().error(">>>>>>>>>>>百融多次申请核查数据落地失败：", e);
						resp.setCode(RespStatus.DATABASE_ERROR.getCode());
						resp.setMsg(RespStatus.DATABASE_ERROR.getMsg());
						status = LocalStatus.IN_DATABASE_FAIL.getCode();
					}
				} else {
					resp.setCode(RespStatus.REQ_ERROR.getCode());
					resp.setMsg("调用百融接口,返回错误码：" + code);
					status = LocalStatus.CALL_SUCCESS.getCode();
				}
			} else {
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
				status = LocalStatus.REQUEST_FAIL.getCode();
			}
		}
		saveDataQueryLogNew(serialNum, loanId, "", occApplyLoanInfo.getSwift_number(), sTime,
				ThirdMethodConstants.BR0042, code, status, "edc_br_data_query_log", "");
		return resp;
	}

	@Override
	public ApiResponse<BddPackAllInterfaceInfo> packgeAllInterfaceInfo(JSONObject json, String serialNum, String loanId,
			String channel) {
		ApiResponse resp = new ApiResponse();
		/*
		 * 如果接口停用，直接返回（视具体情况，有的返回停用，有的返回相关值） ADD BY TUXU 2018-05-31
		 */
		if (PropertiesUtils.isTurnOffForSwitch("switch.br0047")) {
			// RespStatus.DISABLE只有接口停用时才使用定义的这个参数，其它情况按原本的来
			resp.setCode(RespStatus.DISABLE.getCode());
			resp.setMsg(RespStatus.DISABLE.getMsg());
			return resp;
		}
		Date sTime = new Date();
		ThirdProperties thirdProperties = ThirdPropertiesInitUtil.getThirdProperties();
		BddPackAllInterfaceInfo bddPackAllInterfaceInfo = new BddPackAllInterfaceInfo();
		String id = json.get("idNumber").toString();
		String mobile = json.get("mobile").toString();
		String name = json.get("name").toString();
		String bankId = json.get("bankId").toString();
		String tokenId = platLogin();
		String result = "";
		String swift_number = "";
		String code = "";
		String status = LocalStatus.REQUEST_FAIL.getCode();
		if (tokenId.isEmpty() || tokenId.equals("")) {
			resp.setCode(RespStatus.REQ_ERROR.getCode());
			resp.setMsg(RespStatus.REQ_ERROR.getMsg());
		} else {
			JSONObject jsonObject = new JSONObject();
			jsonObject.put("id", id);
			jsonObject.put("meal", "RuleSpecialList,RuleApplyLoan,SpecialList_c,ApplyLoanStr,PayConsumption");
			JSONArray jsonArray = new JSONArray();
			jsonArray.add(mobile);
			jsonObject.put("cell", jsonArray);
			jsonObject.put("name", name);
			jsonObject.put("bank_id", bankId);
			jsonObject.put("gid", "");
			MarvelsLogUtil.getInstance().info("==============保单贷打包调用所有接口请求参数:" + jsonObject.toString() + ",loanId" + loanId);
			try {
				result = BaiRongUtil.urlConnectPost(thirdProperties.getBr_packetRequestUrl(), "tokenid=" + tokenId
						+ "&apiCode=" + thirdProperties.getBr_apiCode() + "&jsonData="
						+ URLEncoder.encode(jsonObject.toString(), "utf-8") + "&checkCode="
						+ BaiRongUtil.getCheckData(jsonObject.toString(), thirdProperties.getBr_apiCode(), tokenId));
			} catch (Exception e) {
				MarvelsLogUtil.getInstance().error(">>>>>>>>>保单贷打包调用所有接口请求loanId" + loanId + ",异常:", e);
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
			if (StringUtils.isNotEmpty(result)) {

				bddPackAllInterfaceInfo = JSON.parseObject(result, BddPackAllInterfaceInfo.class);

				code = bddPackAllInterfaceInfo.getCode();
				if (code.equals("00") || code.equals("100002")) {
					if (code.equals("00")) {
						status = LocalStatus.SUCCESS_WITH_DATA.getCode();
					} else {
						status = LocalStatus.SUCCESS_WITHOUT_DATA.getCode();
					}
					resp.setCode(RespStatus.SUCCESS.getCode());
					resp.setMsg(RespStatus.SUCCESS.getMsg());
					resp.setData(bddPackAllInterfaceInfo);

					// SpecialList_c
					SpecialList specialList = bddPackAllInterfaceInfo.getSpecialListData();
					// ApplyLoanStr
					MultipleApplications multipleApplications = bddPackAllInterfaceInfo.getMultipleApplicationsData();

					// RuleSpecialList RuleApplyLoan
					RuleInformation ruleInformation = bddPackAllInterfaceInfo.getRuleInformationData();

					PaymentConsum paymentConsum = bddPackAllInterfaceInfo.getPaymentConsumData();

					try {

						/** 特殊名单核查 */
						dGBaiRongService.specialListReport(specialList, serialNum, loanId);

						/** 多次申请核查V2 */
						dGBaiRongService.multipleApplicationsReport(multipleApplications, serialNum, loanId);

						/** 百融规则 */
						// dGBaiRongService.ruleReport(ruleInformation,
						// serialNum, loanId);

						/**支付消费*/
						dGBaiRongService.occPaymentConsumReport(paymentConsum, serialNum, loanId);

						EdcBrRuleResult edcBrRuleResult = new EdcBrRuleResult();
						edcBrRuleResult.setCreatedBy("sys");
						edcBrRuleResult.setSerialNum(serialNum);
						edcBrRuleResult.setCreatedDate(new Date());
						edcBrRuleResult.setCustIdNumber(json.get("idNumber").toString());
						edcBrRuleResult.setLoanId(loanId);
						edcBrRuleResult.setRuleFinalDecision(bddPackAllInterfaceInfo.getRule_final_decision());
						edcBrRuleResult.setRuleFinalWeight(bddPackAllInterfaceInfo.getRule_final_weight());
						edcBrRuleResult.setUpdatedBy("sys");
						edcBrRuleResult.setUpdatedDate(new Date());

						/**百融规则结果**/
						long resultId = dGBaiRongService.ruleResult(edcBrRuleResult);

						JSONObject strJson = JSONObject.fromObject(result);
						Iterator ite = strJson.keys();
						List<EdcBrRuleResultDetail> list = new ArrayList<EdcBrRuleResultDetail>();
						EdcBrRuleFlagSign edcBrRuleFlagSignDto = new EdcBrRuleFlagSign();
						while (ite.hasNext()) {
							String key = (String) ite.next();
							String value = strJson.getString(key);
							if (key.contains("Rule_name") || key.contains("Rule_weight")) {
								EdcBrRuleResultDetail edcBrRuleResultDetail = new EdcBrRuleResultDetail();
								edcBrRuleResultDetail.setCreatedBy("sys");
								edcBrRuleResultDetail.setCreatedDate(new Date());
								String ruleCode = "";
								if (key.contains("Rule_name")) {
									ruleCode = key.split("Rule_name_")[1];
								} else {
									ruleCode = key.split("Rule_weight_")[1];
								}
								edcBrRuleResultDetail.setRuleCode(ruleCode);
								edcBrRuleResultDetail.setKey(key);
								edcBrRuleResultDetail.setValue(value);
								edcBrRuleResultDetail.setUpdatedBy("sys");
								edcBrRuleResultDetail.setRuleResultId(String.valueOf(resultId));
								edcBrRuleResultDetail.setUpdatedDate(new Date());
								list.add(edcBrRuleResultDetail);
							}

							if (key.equalsIgnoreCase("flag_rulespeciallist")) {
								edcBrRuleFlagSignDto.setFlagRulespeciallist(value);
							}
							if (key.equalsIgnoreCase("flag_ruleapplyloan")) {
								edcBrRuleFlagSignDto.setFlagRuleapplyloan(value);
							}
							if (key.equalsIgnoreCase("flag_rulespeciallist_bank")) {
								edcBrRuleFlagSignDto.setFlagRulespeciallistBank(value);
							}
							if (key.equalsIgnoreCase("flag_ruleapplyloan_bank")) {
								edcBrRuleFlagSignDto.setFlagRuleapplyloanBank(value);
							}
							if (key.equalsIgnoreCase("flag_ruleaccountchange")) {
								edcBrRuleFlagSignDto.setFlagRuleaccountchange(value);
							}
							if (key.equalsIgnoreCase("flag_ruleaccountchange_bank")) {
								edcBrRuleFlagSignDto.setFlagRuleaccountchangeBank(value);
							}
							if (key.equalsIgnoreCase("flag_ruleaccountchange_c")) {
								edcBrRuleFlagSignDto.setFlagRuleaccountchangeC(value);
							}
							if (key.equalsIgnoreCase("flag_ruleaccountchange_c_bank")) {
								edcBrRuleFlagSignDto.setFlagRuleaccountchangeCBank(value);
							}
							if (key.equalsIgnoreCase("flag_ruleaccountchange_u")) {
								edcBrRuleFlagSignDto.setFlagRuleaccountchangeU(value);
							}
							if (key.equalsIgnoreCase("flag_ruleaccountchange_u_bank")) {
								edcBrRuleFlagSignDto.setFlagRuleaccountchangeUBank(value);
							}
							if (key.equalsIgnoreCase("flag_ruleexecution")) {
								edcBrRuleFlagSignDto.setFlagRuleexecution(value);
							}
							if (key.equalsIgnoreCase("flag_rulescore")) {
								edcBrRuleFlagSignDto.setFlagRulescore(value);
							}
							if (key.equalsIgnoreCase("flag_ruleequipmencheck")) {
								edcBrRuleFlagSignDto.setFlagRuleequipmencheck(value);
							}
							if (key.equalsIgnoreCase("flag_ruleloan_web")) {
								edcBrRuleFlagSignDto.setFlagRuleloanWeb(value);
							}
							if (key.equalsIgnoreCase("flag_ruleloan_android")) {
								edcBrRuleFlagSignDto.setFlagRuleloanAndroid(value);
							}
							if (key.equalsIgnoreCase("flag_ruleloan_ios")) {
								edcBrRuleFlagSignDto.setFlagRuleloanIos(value);
							}
							if (key.equalsIgnoreCase("flag_ruleregister_web")) {
								edcBrRuleFlagSignDto.setFlagRuleregisterWeb(value);
							}

							if (key.equalsIgnoreCase("flag_ruleregister_android")) {
								edcBrRuleFlagSignDto.setFlagRuleregisterAndroid(value);
							}

							if (key.equalsIgnoreCase("flag_ruleregister_ios")) {
								edcBrRuleFlagSignDto.setFlagRuleregisterIos(value);
							}

							if (key.equalsIgnoreCase("flag_rulelog_web")) {
								edcBrRuleFlagSignDto.setFlagRulelogWeb(value);
							}

							if (key.equalsIgnoreCase("flag_rulelog_android")) {
								edcBrRuleFlagSignDto.setFlagRulelogAndroid(value);
							}

							if (key.equalsIgnoreCase("flag_rulelog_ios")) {
								edcBrRuleFlagSignDto.setFlagRulelogIos(value);
							}

							if (key.equalsIgnoreCase("flag_rulecash_web")) {
								edcBrRuleFlagSignDto.setFlagRulecashWeb(value);
							}

							if (key.equalsIgnoreCase("flag_rulecash_android")) {
								edcBrRuleFlagSignDto.setFlagRulecashAndroid(value);
							}

							if (key.equalsIgnoreCase("flag_rulecash_ios")) {
								edcBrRuleFlagSignDto.setFlagRulecashIos(value);
							}

							if (key.equalsIgnoreCase("flag_ruleequipmentspeciallist")) {
								edcBrRuleFlagSignDto.setFlagRuleequipmentspeciallist(value);
							}
							edcBrRuleFlagSignDto.setRuleResultId(String.valueOf(resultId));
						}
						if (list != null && list.size() > 0) {
							dGBaiRongService.ruleResult(list);
						}
						swift_number = bddPackAllInterfaceInfo.getSwift_number();
					} catch (Exception e) {
						MarvelsLogUtil.getInstance().error(">>>>>>>>>>保单贷打包调用所有接口loanId" + loanId + ",落库异常:", e);
						resp.setCode(RespStatus.DATABASE_ERROR.getCode());
						resp.setMsg(RespStatus.DATABASE_ERROR.getMsg());
						status = LocalStatus.IN_DATABASE_FAIL.getCode();
					}
				} else {
					resp.setCode(RespStatus.REQ_ERROR.getCode());
					resp.setMsg("调用百融接口,返回错误码：" + code);
					status = LocalStatus.CALL_SUCCESS.getCode();
				}
			} else {
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
		}


		saveDataQueryLogNew(serialNum, loanId, "", bddPackAllInterfaceInfo.getSwift_number(), sTime, 
				ThirdMethodConstants.BR0047, code, status, "edc_br_data_query_log", "");
		return resp;
	}

	@Override
	public ApiResponse<LoanFacilityPackageInfo> loanFacilityInformationReportPack(Map<String, String> map) {
		ApiResponse<LoanFacilityPackageInfo> resp = new ApiResponse<LoanFacilityPackageInfo>();
		/*
		 * 如果接口停用，直接返回（视具体情况，有的返回停用，有的返回相关值） ADD BY TUXU 2018-05-31
		 */
		if (PropertiesUtils.isTurnOffForSwitch("switch.br0050")) {
			// RespStatus.DISABLE只有接口停用时才使用定义的这个参数，其它情况按原本的来
			resp.setCode(RespStatus.DISABLE.getCode());
			resp.setMsg(RespStatus.DISABLE.getMsg());
			return resp;
		}
		String serialNum = map.get("serialNum");
		String loanId = map.get("loanId");
		String channel = map.get("channel");
		String mobile = map.get("mobile");
		String name = map.get("name");
		String afSwiftNumber = map.get("afSwiftNumber");
		String custIdCard = map.get("custIdCard");
		String code = "";
		String status = LocalStatus.REQUEST_FAIL.getCode();
		Date responseDate = null;
		JSONObject multipleJson = new JSONObject();
		Date sTime = new Date();
		ThirdProperties thirdProperties = ThirdPropertiesInitUtil.getThirdProperties();
		JSONArray array = new JSONArray();
		LoanFacilityPackageInfo loanFacilityPackageInfo = new LoanFacilityPackageInfo();
		array.add(mobile);
		multipleJson.put("cell", array);
		multipleJson.put("id", custIdCard);
		multipleJson.put("name", name);
		multipleJson.put("af_swift_number", afSwiftNumber);
		multipleJson.put("event", "antifraud_lend");
		multipleJson.put("meal", "LoanEquipment,EquipmentCheck,EquipmentSpecialList,EquipmentInfo");
		String tokenId = platLogin();
		String result = "";
		if (tokenId.isEmpty() || tokenId.equals("")) {
			resp.setCode(RespStatus.REQ_ERROR.getCode());
			resp.setMsg(RespStatus.REQ_ERROR.getMsg());
		} else {

			try {

				result = BaiRongUtil.urlConnectPost(thirdProperties.getBr_packetRequestUrl(), "tokenid=" + tokenId
						+ "&apiCode=" + thirdProperties.getBr_apiCode() + "&jsonData="
						+ URLEncoder.encode(multipleJson.toString(), "utf-8") + "&checkCode="
						+ BaiRongUtil.getCheckData(multipleJson.toString(), thirdProperties.getBr_apiCode(), tokenId));
			} catch (Exception e) {
				MarvelsLogUtil.getInstance().error(">>>>>>>>>>>>>百融保单贷借款设备信息核查请求异常", e);
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
			responseDate = new Date();
			if (StringUtils.isNotEmpty(result)) {
				MarvelsLogUtil.getInstance().info("==============百融保单贷借款设备信息核查返回信息:" + result);
				JSONObject resultJson = new JSONObject();
				resultJson = JSONObject.fromObject(result);
				code = resultJson.get("code").toString();
				if (code.equals("00") || code.equals("100002")) {
					if (code.equals("00")) {
						status = LocalStatus.SUCCESS_WITH_DATA.getCode();
					} else {
						status = LocalStatus.SUCCESS_WITHOUT_DATA.getCode();
					}
					loanFacilityPackageInfo = JSON.parseObject(result, LoanFacilityPackageInfo.class);
					resp.setCode(RespStatus.SUCCESS.getCode());
					resp.setMsg(RespStatus.SUCCESS.getMsg());
					resp.setData(loanFacilityPackageInfo);
					// 数据落地
					LoanFacilityInformation loanFacilityInformation = new LoanFacilityInformation();
					EquipmentSpecialList equipmentSpecialList = new EquipmentSpecialList();
					equipmentSpecialList = loanFacilityPackageInfo.getEquipmentSpecialList();
					equipmentSpecialList.setQuery_event("antifraud_lend");
					loanFacilityInformation = loanFacilityPackageInfo.getLoanFacilityInformation();
					EquipmentInfor equipmentInfor = new EquipmentInfor();
					equipmentInfor = loanFacilityPackageInfo.getEquipmentInfor();
					equipmentInfor.setQuery_event("antifraud_lend");
					EquipmentInfo equipmentInfo = new EquipmentInfo();
					equipmentInfo = loanFacilityPackageInfo.getEquipmentInfo();
					equipmentInfo.setQuery_event("antifraud_lend");
					try {
						long id = dGBaiRongService.loanFacilityInformationReport(loanFacilityInformation, serialNum,
								loanId, mobile);
						String foreignId =  String.valueOf(id);
						dGBaiRongService.equipmentSpecialListInfo(equipmentSpecialList, serialNum, loanId, foreignId,mobile);
						dGBaiRongService.equipmentInformationVerification(equipmentInfor, serialNum, loanId, foreignId,mobile);
						dGBaiRongService.equipmentInfo(equipmentInfo, serialNum, loanId, foreignId,mobile);
						// 回写注册 登录 反欺诈表
						edcBrSignequipmentMapper.updateByMobile(loanId, mobile);
						intBrRegisterEquipmentMapper.updateByMobile(loanId, mobile);
					} catch (Exception e) {
						MarvelsLogUtil.getInstance().error(">>>>>>>>>>百融保单贷借款设备信息数据落地失败：", e);
						resp.setCode(RespStatus.DATABASE_ERROR.getCode());
						resp.setMsg(RespStatus.DATABASE_ERROR.getMsg());
						status = LocalStatus.IN_DATABASE_FAIL.getCode();
					}
				} else {
					resp.setCode(RespStatus.REQ_ERROR.getCode());
					resp.setMsg("调用百融接口,返回错误码：" + code);
					status = LocalStatus.CALL_SUCCESS.getCode();
				}
			} else {
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
		}
		saveDataQueryLogNew(serialNum, loanId, "", loanFacilityPackageInfo.getSwift_number(), sTime, 
				ThirdMethodConstants.BR0050, code, status, "edc_br_data_query_log", "");
		return resp;
	}

	@Override
	public ApiResponse<RegisterFacilityPackageInfo> registerFacilityInformationReportPack(Map<String, String> map) {
		ApiResponse<RegisterFacilityPackageInfo> resp = new ApiResponse<RegisterFacilityPackageInfo>();
		/*
		 * 如果接口停用，直接返回（视具体情况，有的返回停用，有的返回相关值） ADD BY TUXU 2018-05-31
		 */
		if (PropertiesUtils.isTurnOffForSwitch("switch.br0051")) {
			// RespStatus.DISABLE只有接口停用时才使用定义的这个参数，其它情况按原本的来
			resp.setCode(RespStatus.DISABLE.getCode());
			resp.setMsg(RespStatus.DISABLE.getMsg());
			return resp;
		}
		String serialNum = map.get("serialNum");
		String loanId = map.get("loanId");
		String mobile = map.get("mobile");
		String name = map.get("name");
		String afSwiftNumber = map.get("afSwiftNumber");
		JSONObject multipleJson = new JSONObject();
		Date sTime = new Date();
		String code = "";
		String status = LocalStatus.REQUEST_FAIL.getCode();
		ThirdProperties thirdProperties = ThirdPropertiesInitUtil.getThirdProperties();
		RegisterFacilityPackageInfo registerFacilityPackageInfo = new RegisterFacilityPackageInfo();
		JSONArray array = new JSONArray();
		array.add(mobile);
		multipleJson.put("cell", array);
		multipleJson.put("name", name);
		multipleJson.put("af_swift_number", afSwiftNumber);
		multipleJson.put("event", "antifraud_register");
		multipleJson.put("meal", "RegisterEquipment,EquipmentCheck,EquipmentSpecialList,EquipmentInfo");
		String tokenId = platLogin();
		String result = "";
		if (tokenId.isEmpty() || tokenId.equals("")) {
			resp.setCode(RespStatus.REQ_ERROR.getCode());
			resp.setMsg(RespStatus.REQ_ERROR.getMsg());
		} else {

			try {
				result = BaiRongUtil.urlConnectPost(thirdProperties.getBr_packetRequestUrl(), "tokenid=" + tokenId
						+ "&apiCode=" + thirdProperties.getBr_apiCode() + "&jsonData="
						+ URLEncoder.encode(multipleJson.toString(), "utf-8") + "&checkCode="
						+ BaiRongUtil.getCheckData(multipleJson.toString(), thirdProperties.getBr_apiCode(), tokenId));
			} catch (Exception e) {
				MarvelsLogUtil.getInstance().error(">>>>>>>>>>>百融保单贷注册设备信息请求异常", e);
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
			if (StringUtils.isNotEmpty(result)) {
				MarvelsLogUtil.getInstance().info("==============百融保单贷注册设备信息返回信息:" + result);
				JSONObject resultJson = new JSONObject();
				resultJson = JSONObject.fromObject(result);
				code = resultJson.get("code").toString();
				if (code.equals("00") || code.equals("100002")) {
					if (code.equals("00")) {
						status = LocalStatus.SUCCESS_WITH_DATA.getCode();
					} else {
						status = LocalStatus.SUCCESS_WITHOUT_DATA.getCode();
					}
					registerFacilityPackageInfo = JSON.parseObject(result, RegisterFacilityPackageInfo.class);
					resp.setCode(RespStatus.SUCCESS.getCode());
					resp.setMsg(RespStatus.SUCCESS.getMsg());
					resp.setData(registerFacilityPackageInfo);
					RegisterFacilityInformation registerFacilityInformation = new RegisterFacilityInformation();
					EquipmentSpecialList equipmentSpecialList = new EquipmentSpecialList();
					equipmentSpecialList = registerFacilityPackageInfo.getEquipmentSpecialList();
					equipmentSpecialList.setQuery_event("antifraud_register");
					registerFacilityInformation = registerFacilityPackageInfo.getRegisterFacilityInformation();
					EquipmentInfor equipmentInfor = new EquipmentInfor();
					equipmentInfor = registerFacilityPackageInfo.getEquipmentInfor();
					equipmentInfor.setQuery_event("antifraud_register");
					EquipmentInfo equipmentInfo = new EquipmentInfo();
					equipmentInfo = registerFacilityPackageInfo.getEquipmentInfo();
					equipmentInfo.setQuery_event("antifraud_register");
					// 数据落地
					try {
						long id = dGBaiRongService.registerFacilityInformationReport(registerFacilityInformation,
								serialNum, loanId, mobile);
						String foreignId = String.valueOf(id);
						dGBaiRongService.equipmentSpecialListInfo(equipmentSpecialList, serialNum, loanId, foreignId,mobile);
						dGBaiRongService.equipmentInformationVerification(equipmentInfor, serialNum, loanId, foreignId,mobile);
						dGBaiRongService.equipmentInfo(equipmentInfo, serialNum, loanId, foreignId,mobile);
					} catch (Exception e) {
						MarvelsLogUtil.getInstance().error(">>>>>>>百融保单贷注册设备信息数据落地失败：", e);
						resp.setCode(RespStatus.DATABASE_ERROR.getCode());
						resp.setMsg(RespStatus.DATABASE_ERROR.getMsg());
						status = LocalStatus.IN_DATABASE_FAIL.getCode();
					}
				} else {
					resp.setCode(RespStatus.REQ_ERROR.getCode());
					resp.setMsg("调用百融接口,返回错误码：" + code);
					status = LocalStatus.CALL_SUCCESS.getCode();
				}
			} else {
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
		}
		saveDataQueryLogNew(mobile, mobile, "", registerFacilityPackageInfo.getSwift_number(), sTime, 
				ThirdMethodConstants.BR0051, code, status, "edc_br_data_query_log", "");

		return resp;
	}

	@Override
	public ApiResponse<LoginFacilityPackageInfo> loginFacilityInformationReportPack(Map<String, String> map) {
		ApiResponse<LoginFacilityPackageInfo> resp = new ApiResponse<LoginFacilityPackageInfo>();
		/*
		 * 如果接口停用，直接返回（视具体情况，有的返回停用，有的返回相关值） ADD BY TUXU 2018-05-31
		 */
		if (PropertiesUtils.isTurnOffForSwitch("switch.br0049")) {
			// RespStatus.DISABLE只有接口停用时才使用定义的这个参数，其它情况按原本的来
			resp.setCode(RespStatus.DISABLE.getCode());
			resp.setMsg(RespStatus.DISABLE.getMsg());
			return resp;
		}
		String serialNum = map.get("serialNum");
		String loanId = map.get("loanId");
		String mobile = map.get("mobile");
		String afSwiftNumber = map.get("afSwiftNumber");
		JSONObject multipleJson = new JSONObject();
		Date sTime = new Date();
		String code = "";
		String status = LocalStatus.REQUEST_FAIL.getCode();
		ThirdProperties thirdProperties = ThirdPropertiesInitUtil.getThirdProperties();
		LoginFacilityPackageInfo loginFacilityPackageInfo = new LoginFacilityPackageInfo();
		JSONArray array = new JSONArray();
		array.add(mobile);
		multipleJson.put("cell", array);
		multipleJson.put("af_swift_number", afSwiftNumber);
		multipleJson.put("event", "antifraud_login");
		multipleJson.put("meal", "SignEquipment,EquipmentCheck,EquipmentSpecialList,EquipmentInfo");
		String tokenId = platLogin();
		String result = "";
		if (tokenId.isEmpty() || tokenId.equals("")) {

			resp.setCode(RespStatus.REQ_ERROR.getCode());
			resp.setMsg(RespStatus.REQ_ERROR.getMsg());
		} else {
			try {
				result = BaiRongUtil.urlConnectPost(thirdProperties.getBr_packetRequestUrl(), "tokenid=" + tokenId
						+ "&apiCode=" + thirdProperties.getBr_apiCode() + "&jsonData="
						+ URLEncoder.encode(multipleJson.toString(), "utf-8") + "&checkCode="
						+ BaiRongUtil.getCheckData(multipleJson.toString(), thirdProperties.getBr_apiCode(), tokenId));
			} catch (Exception e) {
				MarvelsLogUtil.getInstance().error(">>>>>>>>>>>>>>百融保单贷登录设备信息请求异常", e);
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
			if (StringUtils.isNotEmpty(result)) {
				MarvelsLogUtil.getInstance().info("==============百融保单贷登录设备信息返回信息:" + result);
				JSONObject resultJson = new JSONObject();
				resultJson = JSONObject.fromObject(result);
				code = resultJson.get("code").toString();
				if (code.equals("00") || code.equals("100002")) {
					if (code.equals("00")) {
						status = LocalStatus.SUCCESS_WITH_DATA.getCode();
					} else {
						status = LocalStatus.SUCCESS_WITHOUT_DATA.getCode();
					}
					loginFacilityPackageInfo = JSON.parseObject(result, LoginFacilityPackageInfo.class);
					resp.setCode(RespStatus.SUCCESS.getCode());
					resp.setMsg(RespStatus.SUCCESS.getMsg());
					resp.setData(loginFacilityPackageInfo);
					LoginFacilityInformation loginFacilityInformation = new LoginFacilityInformation();
					EquipmentSpecialList equipmentSpecialList = new EquipmentSpecialList();
					equipmentSpecialList = loginFacilityPackageInfo.getEquipmentSpecialList();
					equipmentSpecialList.setQuery_event("antifraud_login");
					loginFacilityInformation = loginFacilityPackageInfo.getLoginFacilityInformation();
					EquipmentInfor equipmentInfor = new EquipmentInfor();
					equipmentInfor = loginFacilityPackageInfo.getEquipmentInfor();
					equipmentInfor.setQuery_event("antifraud_login");
					EquipmentInfo equipmentInfo = new EquipmentInfo();
					equipmentInfo = loginFacilityPackageInfo.getEquipmentInfo();
					equipmentInfo.setQuery_event("antifraud_login");
					// 数据落地
					try {
						long id = dGBaiRongService.loginFacilityInformationReport(loginFacilityInformation, serialNum,
								loanId, mobile);
						String foreignId = String.valueOf(id);
						dGBaiRongService.equipmentSpecialListInfo(equipmentSpecialList, serialNum, loanId, foreignId,mobile);
						dGBaiRongService.equipmentInformationVerification(equipmentInfor, serialNum, loanId, foreignId,mobile);
						dGBaiRongService.equipmentInfo(equipmentInfo, serialNum, loanId, foreignId,mobile);
					} catch (Exception e) {
						MarvelsLogUtil.getInstance().error(">>>>>>>>>>>>>百融保单贷登录设备信息数据落地失败：", e);
						resp.setCode(RespStatus.DATABASE_ERROR.getCode());
						resp.setMsg(RespStatus.DATABASE_ERROR.getMsg());
						status = LocalStatus.IN_DATABASE_FAIL.getCode();
					}
				} else {
					resp.setCode(RespStatus.REQ_ERROR.getCode());
					resp.setMsg("调用百融接口,返回错误码：" + code);
					status = LocalStatus.CALL_SUCCESS.getCode();
				}
			} else {
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
		}
		saveDataQueryLogNew(mobile, mobile, "", loginFacilityPackageInfo.getSwift_number(), sTime,
				ThirdMethodConstants.BR0049, code, status, "edc_br_data_query_log", "");

		return resp;
	}

	@Override
	public ApiResponse<CurrentEquipmentPackageInfo> cashFacilityInformationReportPack(Map<String, String> map) {
		ApiResponse<CurrentEquipmentPackageInfo> resp = new ApiResponse<CurrentEquipmentPackageInfo>();
		/*
		 * 如果接口停用，直接返回（视具体情况，有的返回停用，有的返回相关值） ADD BY TUXU 2018-05-31
		 */
		if (PropertiesUtils.isTurnOffForSwitch("switch.br0052")) {
			// RespStatus.DISABLE只有接口停用时才使用定义的这个参数，其它情况按原本的来
			resp.setCode(RespStatus.DISABLE.getCode());
			resp.setMsg(RespStatus.DISABLE.getMsg());
			return resp;
		}
		String serialNum = map.get("serialNum");
		String loanId = map.get("loanId");
		String mobile = map.get("mobile");
		String name = map.get("name");
		String afSwiftNumber = map.get("afSwiftNumber");
		String custIdCard = map.get("custIdCard");
		String code = "";
		String status = LocalStatus.REQUEST_FAIL.getCode();
		JSONObject multipleJson = new JSONObject();
		Date sTime = new Date();
		ThirdProperties thirdProperties = ThirdPropertiesInitUtil.getThirdProperties();
		CurrentEquipmentPackageInfo currentEquipmentPackageInfo = new CurrentEquipmentPackageInfo();
		JSONArray array = new JSONArray();
		array.add(mobile);
		multipleJson.put("cell", array);
		multipleJson.put("name", name);
		multipleJson.put("id", custIdCard);
		multipleJson.put("af_swift_number", afSwiftNumber);
		multipleJson.put("event", "antifraud_cash");
		multipleJson.put("meal", "CashEquipment,EquipmentCheck,EquipmentSpecialList,EquipmentInfo");
		String tokenId = platLogin();
		String result = "";
		if (tokenId.isEmpty() || tokenId.equals("")) {

			resp.setCode(RespStatus.REQ_ERROR.getCode());
			resp.setMsg(RespStatus.REQ_ERROR.getMsg());
		} else {

			try {
				result = BaiRongUtil.urlConnectPost(thirdProperties.getBr_packetRequestUrl(), "tokenid=" + tokenId
						+ "&apiCode=" + thirdProperties.getBr_apiCode() + "&jsonData="
						+ URLEncoder.encode(multipleJson.toString(), "utf-8") + "&checkCode="
						+ BaiRongUtil.getCheckData(multipleJson.toString(), thirdProperties.getBr_apiCode(), tokenId));
			} catch (Exception e) {
				MarvelsLogUtil.getInstance().error(">>>>>>>>>>>百融保单贷提现设备信息请求异常", e);
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
			if (StringUtils.isNotEmpty(result)) {
				MarvelsLogUtil.getInstance().info("==============百融保单贷提现设备信息返回信息:" + result);
				JSONObject resultJson = new JSONObject();
				resultJson = JSONObject.fromObject(result);
				code = resultJson.get("code").toString();
				if (code.equals("00") || code.equals("100002")) {
					if (code.equals("00")) {
						status = LocalStatus.SUCCESS_WITH_DATA.getCode();
					} else {
						status = LocalStatus.SUCCESS_WITHOUT_DATA.getCode();
					}
					currentEquipmentPackageInfo = JSON.parseObject(result, CurrentEquipmentPackageInfo.class);
					resp.setCode(RespStatus.SUCCESS.getCode());
					resp.setMsg(RespStatus.SUCCESS.getMsg());
					resp.setData(currentEquipmentPackageInfo);
					CurrentEquipmentInformationReport currentEquipmentInformationReport = new CurrentEquipmentInformationReport();
					EquipmentSpecialList equipmentSpecialList = new EquipmentSpecialList();
					equipmentSpecialList = currentEquipmentPackageInfo.getEquipmentSpecialList();
					equipmentSpecialList.setQuery_event("antifraud_cash");
					currentEquipmentInformationReport = currentEquipmentPackageInfo
							.getCurrentEquipmentInformationReport();
					EquipmentInfor equipmentInfor = new EquipmentInfor();
					equipmentInfor = currentEquipmentPackageInfo.getEquipmentInfor();
					equipmentInfor.setQuery_event("antifraud_cash");
					EquipmentInfo equipmentInfo = new EquipmentInfo();
					equipmentInfo = currentEquipmentPackageInfo.getEquipmentInfo();
					equipmentInfo.setQuery_event("antifraud_cash");
					// 数据落地
					try {
						dGBaiRongService.cashFacilityInformationReport(currentEquipmentInformationReport, serialNum,
								loanId, mobile);
						dGBaiRongService.equipmentSpecialListInfo(equipmentSpecialList, serialNum, loanId, "",mobile);
						dGBaiRongService.equipmentInformationVerification(equipmentInfor, serialNum, loanId, "",mobile);
						dGBaiRongService.equipmentInfo(equipmentInfo, serialNum, loanId, "",mobile);
					} catch (Exception e) {
						MarvelsLogUtil.getInstance().error(">>>>>>>>>>>百融保单贷提现设备信息数据落地失败：", e);
						resp.setCode(RespStatus.DATABASE_ERROR.getCode());
						resp.setMsg(RespStatus.DATABASE_ERROR.getMsg());
						status = LocalStatus.IN_DATABASE_FAIL.getCode();
					}
				} else {
					resp.setCode(RespStatus.REQ_ERROR.getCode());
					resp.setMsg("调用百融接口,返回错误码：" + code);
					status = LocalStatus.CALL_SUCCESS.getCode();
				}
			} else {
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
		}
		saveDataQueryLogNew(serialNum, loanId, "", currentEquipmentPackageInfo.getSwift_number(), sTime, 
				ThirdMethodConstants.BR0052, code, status, "edc_br_data_query_log", "");

		return resp;
	}

	/**
	 * 商城打包调用百融数据所有接口
	 * @param json
	 * @param serialNum
	 * @param loanId
	 * @param channel
	 * @return
	 */
	@Override
	public ApiResponse<BddPackAllInterfaceInfo> packgeAllBrInterfaceInfoForMall(JSONObject json, String serialNum,
			String loanId, String channel) {

		ApiResponse resp = new ApiResponse();
		/*
		 * 如果接口停用，直接返回（视具体情况，有的返回停用，有的返回相关值） ADD BY TUXU 2018-05-31
		 */
		if (PropertiesUtils.isTurnOffForSwitch("switch.br0048")) {
			// RespStatus.DISABLE只有接口停用时才使用定义的这个参数，其它情况按原本的来
			resp.setCode(RespStatus.DISABLE.getCode());
			resp.setMsg(RespStatus.DISABLE.getMsg());
			return resp;
		}
		Date sTime = new Date();
		ThirdProperties thirdProperties = ThirdPropertiesInitUtil.getThirdProperties();
		MallBrAllInterfaceInfo mallBrAllInterfaceInfo = new MallBrAllInterfaceInfo();
		String id = json.get("idNumber").toString();
		String mobile = json.get("mobile").toString();
		String name = json.get("name").toString();
		// String bankId=json.get("bankId").toString();
		String tokenId = platLogin();
		String result = "";
		String code = "";
		String status = LocalStatus.REQUEST_FAIL.getCode();
		if (tokenId.isEmpty() || tokenId.equals("")) {
			resp.setCode(RespStatus.REQ_ERROR.getCode());
			resp.setMsg(RespStatus.REQ_ERROR.getMsg());
		} else {
			JSONObject jsonObject = new JSONObject();
			jsonObject.put("id", id);
			/*多次申请核查V2(ApplyLoanStr)、申请信息关联(InfoRelation)、特殊名单规则(SpecialList_c)、百融非银消费贷线下评分V2.0(scoreconsoffv2)、
			 * 百融规则（RuleSpecialList,RuleApplyLoan,RuleAccountChange,RuleScore）、小贷款评分（scorepettycashv1）*/
			jsonObject.put("meal", "RuleSpecialList,RuleApplyLoan,SpecialList_c,ApplyLoanStr,InfoRelation");
			// SpecialList_c,ApplyLoanStr,AccountchangeMonth,scoreconsoffv2,RuleSpecialList,RuleApplyLoan,RuleAccountChange,RuleScore,InfoRelation,RuleInfoRelation
			JSONArray jsonArray = new JSONArray();
			jsonArray.add(mobile);
			jsonObject.put("cell", jsonArray);
			jsonObject.put("name", name);
			jsonObject.put("gid", "");
			MarvelsLogUtil.getInstance().info("==============商城打包调用所有接口请求参数:" + jsonObject.toString() + ",loanId" + loanId);
			try {
				result = BaiRongUtil.urlConnectPost(thirdProperties.getBr_packetRequestUrl(), "tokenid=" + tokenId
						+ "&apiCode=" + thirdProperties.getBr_apiCode() + "&jsonData="
						+ URLEncoder.encode(jsonObject.toString(), "utf-8") + "&checkCode="
						+ BaiRongUtil.getCheckData(jsonObject.toString(), thirdProperties.getBr_apiCode(), tokenId));
				MarvelsLogUtil.getInstance().info("==============商城打包调用所有接口返回参数:" + result + ",loanId" + loanId);
			} catch (Exception e) {
				MarvelsLogUtil.getInstance().error(">>>>>>>>>>商城打包调用所有接口请求异常,loanId" + loanId, e);
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
				status = LocalStatus.REQUEST_FAIL.getCode();
			}
			if (StringUtils.isNotEmpty(result)) {

				mallBrAllInterfaceInfo = JSON.parseObject(result, MallBrAllInterfaceInfo.class);

				code = mallBrAllInterfaceInfo.getCode();
				if (code.equals("00") || code.equals("100002")) {
					if (code.equals("00")) {
						status = LocalStatus.SUCCESS_WITH_DATA.getCode();
					} else {
						status = LocalStatus.SUCCESS_WITHOUT_DATA.getCode();
					}
					resp.setCode(RespStatus.SUCCESS.getCode());
					resp.setMsg(RespStatus.SUCCESS.getMsg());
					resp.setData(mallBrAllInterfaceInfo);

					// SpecialList_c
					SpecialList specialList = mallBrAllInterfaceInfo.getSpecialListData();
					// ApplyLoanStr
					MultipleApplications multipleApplications = mallBrAllInterfaceInfo.getMultipleApplicationsData();

					ApplicationInfoAssociate applicationInfoAssociate = mallBrAllInterfaceInfo
							.getApplicationInfoAssociate();

					/*小贷款评分*/
					Score score = mallBrAllInterfaceInfo.getScoreData();

					try {
						/** 特殊名单核查 */
						dGBaiRongService.specialListReport(specialList, serialNum, loanId);
						MarvelsLogUtil.getInstance().info("=========落库特殊名单核查成功");

						/** 多次申请核查V2 */
						dGBaiRongService.multipleApplicationsReport(multipleApplications, serialNum, loanId);
						MarvelsLogUtil.getInstance().info("=========落库多次申请核查V2成功");

						/**申请信息关联*/
						dGBaiRongService.applicationInfoAssociate(applicationInfoAssociate, serialNum, loanId);
						MarvelsLogUtil.getInstance().info("=========落库申请信息关联成功");

						/**小贷评分*/
						/*dGBaiRongService.scoreReport(score, serialNum, loanId);
						MarvelsLogUtil.getInstance().info("=========落库小贷评分成功");*/

						EdcBrRuleResult edcBrRuleResult = new EdcBrRuleResult();
						edcBrRuleResult.setCreatedBy("sys");
						edcBrRuleResult.setSerialNum(serialNum);
						edcBrRuleResult.setCreatedDate(new Date());
						edcBrRuleResult.setCustIdNumber(json.get("idNumber").toString());
						edcBrRuleResult.setLoanId(loanId);
						edcBrRuleResult.setRuleFinalDecision(mallBrAllInterfaceInfo.getRule_final_decision());
						edcBrRuleResult.setRuleFinalWeight(mallBrAllInterfaceInfo.getRule_final_weight());
						edcBrRuleResult.setUpdatedBy("sys");
						edcBrRuleResult.setUpdatedDate(new Date());

						/**百融规则结果**/
						long resultId = dGBaiRongService.ruleResult(edcBrRuleResult);

						JSONObject strJson = JSONObject.fromObject(result);
						Iterator ite = strJson.keys();
						List<EdcBrRuleResultDetail> list = new ArrayList<EdcBrRuleResultDetail>();
						EdcBrRuleFlagSign edcBrRuleFlagSignDto = new EdcBrRuleFlagSign();
						while (ite.hasNext()) {
							String key = (String) ite.next();
							String value = strJson.getString(key);
							if (key.contains("Rule_name") || key.contains("Rule_weight")) {
								EdcBrRuleResultDetail edcBrRuleResultDetail = new EdcBrRuleResultDetail();
								edcBrRuleResultDetail.setCreatedBy("sys");
								edcBrRuleResultDetail.setCreatedDate(new Date());
								String ruleCode = "";
								if (key.contains("Rule_name")) {
									ruleCode = key.split("Rule_name_")[1];
								} else {
									ruleCode = key.split("Rule_weight_")[1];
								}
								edcBrRuleResultDetail.setRuleCode(ruleCode);
								edcBrRuleResultDetail.setKey(key);
								edcBrRuleResultDetail.setValue(value);
								edcBrRuleResultDetail.setUpdatedBy("sys");
								edcBrRuleResultDetail.setRuleResultId(String.valueOf(resultId));
								edcBrRuleResultDetail.setUpdatedDate(new Date());
								list.add(edcBrRuleResultDetail);
							}

							if (key.equalsIgnoreCase("flag_rulespeciallist")) {
								edcBrRuleFlagSignDto.setFlagRulespeciallist(value);
							}
							if (key.equalsIgnoreCase("flag_ruleapplyloan")) {
								edcBrRuleFlagSignDto.setFlagRuleapplyloan(value);
							}
							if (key.equalsIgnoreCase("flag_rulespeciallist_bank")) {
								edcBrRuleFlagSignDto.setFlagRulespeciallistBank(value);
							}
							if (key.equalsIgnoreCase("flag_ruleapplyloan_bank")) {
								edcBrRuleFlagSignDto.setFlagRuleapplyloanBank(value);
							}
							if (key.equalsIgnoreCase("flag_ruleaccountchange")) {
								edcBrRuleFlagSignDto.setFlagRuleaccountchange(value);
							}
							if (key.equalsIgnoreCase("flag_ruleaccountchange_bank")) {
								edcBrRuleFlagSignDto.setFlagRuleaccountchangeBank(value);
							}
							if (key.equalsIgnoreCase("flag_ruleaccountchange_c")) {
								edcBrRuleFlagSignDto.setFlagRuleaccountchangeC(value);
							}
							if (key.equalsIgnoreCase("flag_ruleaccountchange_c_bank")) {
								edcBrRuleFlagSignDto.setFlagRuleaccountchangeCBank(value);
							}
							if (key.equalsIgnoreCase("flag_ruleaccountchange_u")) {
								edcBrRuleFlagSignDto.setFlagRuleaccountchangeU(value);
							}
							if (key.equalsIgnoreCase("flag_ruleaccountchange_u_bank")) {
								edcBrRuleFlagSignDto.setFlagRuleaccountchangeUBank(value);
							}
							if (key.equalsIgnoreCase("flag_ruleexecution")) {
								edcBrRuleFlagSignDto.setFlagRuleexecution(value);
							}
							if (key.equalsIgnoreCase("flag_rulescore")) {
								edcBrRuleFlagSignDto.setFlagRulescore(value);
							}
							if (key.equalsIgnoreCase("flag_ruleequipmencheck")) {
								edcBrRuleFlagSignDto.setFlagRuleequipmencheck(value);
							}
							if (key.equalsIgnoreCase("flag_ruleloan_web")) {
								edcBrRuleFlagSignDto.setFlagRuleloanWeb(value);
							}
							if (key.equalsIgnoreCase("flag_ruleloan_android")) {
								edcBrRuleFlagSignDto.setFlagRuleloanAndroid(value);
							}
							if (key.equalsIgnoreCase("flag_ruleloan_ios")) {
								edcBrRuleFlagSignDto.setFlagRuleloanIos(value);
							}
							if (key.equalsIgnoreCase("flag_ruleregister_web")) {
								edcBrRuleFlagSignDto.setFlagRuleregisterWeb(value);
							}

							if (key.equalsIgnoreCase("flag_ruleregister_android")) {
								edcBrRuleFlagSignDto.setFlagRuleregisterAndroid(value);
							}

							if (key.equalsIgnoreCase("flag_ruleregister_ios")) {
								edcBrRuleFlagSignDto.setFlagRuleregisterIos(value);
							}

							if (key.equalsIgnoreCase("flag_rulelog_web")) {
								edcBrRuleFlagSignDto.setFlagRulelogWeb(value);
							}

							if (key.equalsIgnoreCase("flag_rulelog_android")) {
								edcBrRuleFlagSignDto.setFlagRulelogAndroid(value);
							}

							if (key.equalsIgnoreCase("flag_rulelog_ios")) {
								edcBrRuleFlagSignDto.setFlagRulelogIos(value);
							}

							if (key.equalsIgnoreCase("flag_rulecash_web")) {
								edcBrRuleFlagSignDto.setFlagRulecashWeb(value);
							}

							if (key.equalsIgnoreCase("flag_rulecash_android")) {
								edcBrRuleFlagSignDto.setFlagRulecashAndroid(value);
							}

							if (key.equalsIgnoreCase("flag_rulecash_ios")) {
								edcBrRuleFlagSignDto.setFlagRulecashIos(value);
							}

							if (key.equalsIgnoreCase("flag_ruleequipmentspeciallist")) {
								edcBrRuleFlagSignDto.setFlagRuleequipmentspeciallist(value);
							}
							edcBrRuleFlagSignDto.setRuleResultId(String.valueOf(resultId));
						}
						if (list != null && list.size() > 0) {
							dGBaiRongService.ruleResult(list);
							MarvelsLogUtil.getInstance().info("=========落库百融规则成功");
						}
					} catch (Exception e) {
						MarvelsLogUtil.getInstance().error(">>>>>>>商城打包调用所有接口落库异常,loanId" + loanId, e);
						resp.setCode(RespStatus.DATABASE_ERROR.getCode());
						resp.setMsg(RespStatus.DATABASE_ERROR.getMsg());
						status = LocalStatus.IN_DATABASE_FAIL.getCode();
					}
				} else {
					resp.setCode(RespStatus.REQ_ERROR.getCode());
					resp.setMsg("调用百融接口,返回错误码：" + code);
					status = LocalStatus.CALL_SUCCESS.getCode();
				}
			} else {
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
		}

		saveDataQueryLogNew(serialNum, loanId, "", mallBrAllInterfaceInfo.getSwift_number(), sTime,
				ThirdMethodConstants.BR0048, code, status, "edc_br_data_query_log", "");

		return resp;

	}

	/**
	 * 查询信用风险识别分数
	 */
	@Override
	public ApiResponse<CreditRiskEvaluation> queryCreditRiskEvaluation(JSONObject json, String serialNum, String loanId,
			String channel) {
		MarvelsLogUtil.getInstance().info("====百融信用风险识别请求方法开始，loan：" + loanId + ",json:" + json.toString());
		ApiResponse<CreditRiskEvaluation> resp = new ApiResponse<CreditRiskEvaluation>();
		/*
		 * 如果接口停用，直接返回（视具体情况，有的返回停用，有的返回相关值） ADD BY TUXU 2018-05-31
		 */
		if (PropertiesUtils.isTurnOffForSwitch("switch.br0055")) {
			// RespStatus.DISABLE只有接口停用时才使用定义的这个参数，其它情况按原本的来
			resp.setCode(RespStatus.DISABLE.getCode());
			resp.setMsg(RespStatus.DISABLE.getMsg());
			return resp;
		}
		ThirdProperties thirdProperties = ThirdPropertiesInitUtil.getThirdProperties();
		String tokenId = platLogin();
		json.put("meal", "scorelargecashv2");
		String mobile = json.getString("cell");
		CreditRiskEvaluation creditRiskEvaluation = new CreditRiskEvaluation();
		Date sTime = new Date();
		String result = "";
		String code = "";
		String status = LocalStatus.REQUEST_FAIL.getCode();
		if (StringUtils.isEmpty(tokenId)) {
			resp.setCode(RespStatus.REQ_ERROR.getCode());
			resp.setMsg(RespStatus.REQ_ERROR.getMsg());
		} else {
			try {
				String url = thirdProperties.getBr_packetRequestUrl();
				String parameter = "tokenid=" + tokenId + "&apiCode=" + thirdProperties.getBr_apiCode() + "&jsonData="
						+ URLEncoder.encode(json.toString(), "utf-8") + "&checkCode="
						+ BaiRongUtil.getCheckData(json.toString(), thirdProperties.getBr_apiCode(), tokenId);
				MarvelsLogUtil.getInstance().info("====百融信用风险识别url:" + url);
				MarvelsLogUtil.getInstance().info("====百融信用风险识别parameter:" + parameter);
				result = BaiRongUtil.urlConnectPost(url, parameter);
			} catch (Exception e) {
				MarvelsLogUtil.getInstance().error(">>>>>>>>>百融信用风险识别请求:", e);
			}
			if (StringUtils.isNotEmpty(result)) {
				MarvelsLogUtil.getInstance().info("==============>>>>百融信用风险识别返回信息:" + result);
				JSONObject resultJson = JSONObject.fromObject(result);
				code = resultJson.getString("code");
				if (code.equals("00") || code.equals("100002")) {
					if (code.equals("00")) {
						status = LocalStatus.SUCCESS_WITH_DATA.getCode();
					} else {
						status = LocalStatus.SUCCESS_WITHOUT_DATA.getCode();
					}
					creditRiskEvaluation = JSON.parseObject(result, CreditRiskEvaluation.class);
					creditRiskEvaluation.setId_number(json.getString("id"));
					creditRiskEvaluation.setCell(mobile);
					creditRiskEvaluation.setUser_name(json.getString("name"));
					resp.setCode(RespStatus.SUCCESS.getCode());
					resp.setMsg(RespStatus.SUCCESS.getMsg());
					resp.setData(creditRiskEvaluation);
					// 数据落地
					try {
						dGBaiRongService.insertCreditRiskEvaluation(creditRiskEvaluation, serialNum, loanId);
					} catch (Exception e) {
						resp.setCode(RespStatus.DATABASE_ERROR.getCode());
						resp.setMsg(RespStatus.DATABASE_ERROR.getMsg());
						status = LocalStatus.IN_DATABASE_FAIL.getCode();
						MarvelsLogUtil.getInstance().error(">>>>>>>>>>>>百融信用风险识别数据落地失败：", e);
					}
				} else {
					status = LocalStatus.CALL_SUCCESS.getCode();
					resp.setCode(RespStatus.REQ_ERROR.getCode());
					resp.setMsg("调用百融信用风险识别异常,返回错误码：" + code);
				}
			} else {
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
		}
		saveDataQueryLogNew(serialNum, loanId, mobile, creditRiskEvaluation.getSwift_number(), sTime,
				ThirdMethodConstants.BR0055, code, status, "edc_br_data_query_log", "");
		return resp;
	}

	/**
	 * 根据loanId查询百融数据
	 * @param loanId
	 * @return
	 */
	@Override
	public List<EdcBRDataQueryLogInfo> findEdcBRDataQueryLogInfo(String loanId) {
		List<EdcBRDataQueryLogInfo> logInfos = edcBRDataQueryLogInfoMapper.findEdcBRDataByLoanId(loanId);
		return logInfos;
	}
}
